Maven构建期间发生错误:
[错误]无法在项目cc-distFS上执行目标org.apache.maven.plugins:maven-jar-plugin:2.4:jar(default-jar):组装JAR时出错:无法读取以下文件系统属性:/ home / user / trunk / src / cc-distFS / pom.xml:无法引用目录:'/ home / user / strunk / src / cc-divist / pom.xml':设置环境变量时出错:NullPointerException - > [帮助1]
maven -X package
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:167)
at org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:163)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error assembling JAR
at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:237)
at org.apache.maven.plugin.jar.AbstractJarMojo.execute(AbstractJarMojo.java:255)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 13 more
Caused by: org.codehaus.plexus.archiver.ArchiverException: Failed to read filesystem attributes for: /home/user/trunk/src/cc-dto/pom.xml
at org.codehaus.plexus.archiver.ArchiveEntry.createFileEntry(ArchiveEntry.java:163)
at org.codehaus.plexus.archiver.AbstractArchiver.addFile(AbstractArchiver.java:404)
at org.codehaus.plexus.archiver.AbstractArchiver.addFile(AbstractArchiver.java:316)
at org.apache.maven.archiver.MavenArchiver.createArchive(MavenArchiver.java:526)
at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:230)
... 16 more
Caused by: java.io.IOException: Failed to quote directory: '/home/user/trunk/src/cc-dto/pom.xml'
at org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributeUtils.getFileAttributesByPath(PlexusIoResourceAttributeUtils.java:256)
at org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributeUtils.getFileAttributes(PlexusIoResourceAttributeUtils.java:172)
at org.codehaus.plexus.archiver.ArchiveEntry.createFileEntry(ArchiveEntry.java:159)
... 20 more
Caused by: org.codehaus.plexus.util.cli.CommandLineException: Error setting up environmental variables
at org.codehaus.plexus.util.cli.Commandline.getEnvironmentVariables(Commandline.java:466)
at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:628)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLineAsCallable(CommandLineUtils.java:140)
at org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributeUtils.getFileAttributesByPath(PlexusIoResourceAttributeUtils.java:247)
... 22 more
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:394)
at org.codehaus.plexus.util.cli.CommandLineUtils.getEnvFromSystem(CommandLineUtils.java:624)
at org.codehaus.plexus.util.cli.CommandLineUtils.getSystemEnvVars(CommandLineUtils.java:284)
at org.codehaus.plexus.util.cli.CommandLineUtils.getSystemEnvVars(CommandLineUtils.java:260)
at org.codehaus.plexus.util.cli.Commandline.addSystemEnvironment(Commandline.java:442)
at org.codehaus.plexus.util.cli.Commandline.getEnvironmentVariables(Commandline.java:462)
... 25 more
有人知道这是什么意思吗?
PS:
% mvn -v
Apache Maven 3.0.4 (r1232337; 2012-01-17 15:44:56+0700)
Maven home: /home/user/Applications/apache-maven
Java version: 1.6.0_27, vendor: Sun Microsystems Inc.
Java home: /home/user/Applications/jdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-26-generic-pae", arch: "i386", family: "unix"
% java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
模块cc-distFS的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.uc</groupId>
<artifactId>cc</artifactId>
<version>TRUNK-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>${parent.groupId}</groupId>
<artifactId>cc-distFS</artifactId>
<packaging>jar</packaging>
<version>${parent.version}</version>
<name>${pom.artifactId}</name>
<dependencies>
<dependency>
<groupId>com.cc</groupId>
<artifactId>cc-lib</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
</dependencies>
PS:在我做了fsck后,Bug消失了。
答案 0 :(得分:1)
首先有点奇怪的是:
<groupId>${parent.groupId}</groupId>
<artifactId>cc-distFS</artifactId>
<packaging>jar</packaging>
<version>${parent.version}</version>
<name>${pom.artifactId}</name>
你永远不应该使用$ {pom ....}或$ {parent.groupId}。你应该改为$ {project.groupId}等。
但是如果你有一个父类,则既不需要groupId也不需要该类型的定义,因为它继承自你的父类。换句话说,您的代码段如下所示:
<parent>
<groupId>com.uc</groupId>
<artifactId>cc</artifactId>
<version>TRUNK-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>cc-distFS</artifactId>
<name>${project.artifactId}</name>
此外,像“TRUNK-SNAPSHOT”这样的版本并不是一个真正的好选择。我建议像rules describe一样使用更像“1.0-SNAPSHOT”的东西。 还有一件事,如果你有父母,你不需要在父母中定义一个相对路径,结果如下:
<parent>
<groupId>com.uc</groupId>
<artifactId>cc</artifactId>
<version>TRUNK-SNAPSHOT</version>
</parent>
<artifactId>cc-distFS</artifactId>
<name>${project.artifactId}</name> <!-- I wouldn't do that -->
但是让我怀疑的是以下几点:
Failed to read filesystem attributes for: /home/user/trunk/src/cc-dto/pom.xml
因为这表明你的pom.xml文件或目录有问题吗? (权限?)以下内容肯定是您的目录出现问题的提示:
java.io.IOException: Failed to quote directory: '/home/user/trunk/src/cc-dto/pom.xml'