Maven构建失败并出现错误:无法在指定路径找到工件 - 路径稍微不正确

时间:2013-04-17 07:01:51

标签: java linux maven hadoop

运行此命令:

mvn package -Pcdh4

这是maven中的错误:

[ERROR] Failed to execute goal on project hdfs-nfs-proxy: 
Could not resolve dependencies for project 
com.cloudera:hdfs-nfs-proxy:jar:0.8.1: 
Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path 
/usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar -> [Help 1]

这是路径中/../返回目录的最后一行,路径应为:

/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/tools.jar

我对maven不太了解或者它在哪里采用这条路径,我只是想按照一些构建说明进行操作。


使用Debug:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.730s
[INFO] Finished at: Wed Apr 17 07:06:39 UTC 2013
[INFO] Final Memory: 8M/360M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hdfs-nfs-proxy: Could not resolve dependencies for project com.cloudera:hdfs-nfs-proxy:jar:0.8.1: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project hdfs-nfs-proxy: Could not resolve dependencies for project com.cloudera:hdfs-nfs-proxy:jar:0.8.1: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:210)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:117)
        at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:258)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:201)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.cloudera:hdfs-nfs-proxy:jar:0.8.1: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:189)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:185)
        ... 22 more
Caused by: org.sonatype.aether.resolution.DependencyResolutionException: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
        at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:375)
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:183)
        ... 23 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
        at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:358)
        ... 24 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:256)
        ... 26 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

mvn -v

root@hadoop-hdfsnfsproxy1:/opt/hdfs-nfs-proxy-release-0.8.1# mvn -v
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_15, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-27-generic", arch: "amd64", family: "unix"
root@hadoop-hdfsnfsproxy1:/opt/hdfs-nfs-proxy-release-0.8.1#

2 个答案:

答案 0 :(得分:6)

您的JAVA_HOME应该指向JDK而不是JRE:tools.jar是位于JDK的lib目录中的lib。

答案 1 :(得分:1)

在Linux / Ubuntu框中安装Sun JDK并将JAVA_HOME指向已安装的JDK

reference link