0

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/trunk/src/cc-distFS/pom.xml':设置环境变量时出错:NullPointerException -> [帮助1]

maven -X 包

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 消失了。

4

1 回答 1

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”这样的版本并不是一个真正好的选择。我建议使用更像规则描述的“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'
于 2012-06-28T17:49:42.890 回答