2012-06-28 55 views
0

錯誤該Maven構建期間發生:NPE在行家-JAR-插件

[ERROR]未能執行目標org.apache.maven.plugins:行家-JAR-插件:2.4:罐(缺省罐)關於項目cc-distFS:組裝JAR時出錯:無法讀取文件系統屬性:/home/user/trunk/src/cc-distFS/pom.xml:無法引用目錄:'/ home/user/trunk/src/cc -distFS/pom.xml中':錯誤設置的環境變量:的NullPointerException - > [幫助1]

行家-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 

Anyb ody知道這是什麼意思?

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) 

pom.xml的用於模塊CC-distFS:

<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。

+0

沒有您使用的POM很難知道什麼是錯誤的... – khmarbaise

+0

是的。我爲模塊cc-distFS附加了pom.xml。主要的pom.xml非常大.. –

回答

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> 

而且像「樹幹快照」的一個版本是不是一個真正的好選擇。我會建議使用更像「1.0-SNAPSHOT」的東西,如rules describe。 還有一件事,如果你有一個家長,你不需要定義你的父母這將導致到下面的相對路徑:

<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' 
+0

錯誤消失後,我做了fsck。但非常感謝您的回答! –