2016-12-18 60 views
0

我有一個在eclipse上完美工作的項目,但是當我嘗試在使用jar文件的終端上運行它時,出現錯誤。基本上,目標是創建一個包含所有依賴關係的胖罐子。使用maven無效或損壞的jarfile

的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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.scryAnalytics</groupId> 
    <artifactId>NLPAnnotationController</artifactId> 
    <version>1.0</version> 
    <packaging>jar</packaging> 

    <name>NLPAnnotationController</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <hadoop.version>2.6.0-cdh5.5.1</hadoop.version> 
     <jdk.version>1.7</jdk.version> 
     <hbase.version>1.0.0-cdh5.5.1</hbase.version> 
    </properties> 

    <repositories> 
     <repository> 
      <id>cloudera</id> 
      <url>https://repository.cloudera.com/cloudera/cloudera-repos</url> 
       </repository> 
       <repository> 
         <id>maven</id> 
         <url>https://repository.apache.org/content/</url> 
       </repository> 

     </repositories> 


    <dependencies> 


<dependency> 
       <groupId>org.apache.hadoop</groupId> 
       <artifactId>hadoop-hdfs</artifactId> 
       <version>2.6.0-cdh5.5.1</version> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.hadoop</groupId> 
       <artifactId>hadoop-auth</artifactId> 
       <version>2.6.0-cdh5.5.1</version> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.hadoop</groupId> 
       <artifactId>hadoop-common</artifactId> 
       <version>2.6.0-cdh5.5.1</version> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.hadoop</groupId> 
       <artifactId>hadoop-yarn-api</artifactId> 
       <version>2.6.0-cdh5.5.1</version> 
      </dependency> 
    <dependency> 
       <groupId>org.apache.hadoop</groupId> 
       <artifactId>hadoop-mapreduce-client-app</artifactId> 
       <version>2.6.0-cdh5.5.1</version> 
      </dependency> 
<dependency> 
       <groupId>org.apache.hadoop</groupId> 
       <artifactId>hadoop-mapreduce-client-common</artifactId> 
       <version>2.6.0-cdh5.5.1</version> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.hadoop</groupId> 
       <artifactId>hadoop-mapreduce-client-core</artifactId> 
       <version>2.6.0-cdh5.5.1</version> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.hadoop</groupId> 


<artifactId>hadoop-yarn-client</artifactId> 
      <version>2.6.0-cdh5.5.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.hbase</groupId> 
      <artifactId>hbase-client</artifactId> 
      <version>1.0.0-cdh5.5.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.hbase</groupId> 
      <artifactId>hbase-common</artifactId> 
      <version>1.0.0-cdh5.5.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.hbase</groupId> 
      <artifactId>hbase-server</artifactId> 
      <version>1.0.0-cdh5.5.1</version> 
     </dependency> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-core-asl</artifactId> 
     <version>1.9.13</version> 
    </dependency> 

    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-mapper-asl</artifactId> 
     <version>1.9.13</version> 
    </dependency> 


    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.10</version> 
     <scope>test</scope> 
    </dependency> 



    <dependency> 
     <groupId>uk.ac.gate</groupId> 
     <artifactId>gate-core</artifactId> 
     <version>8.1</version> 
    </dependency> 
    <dependency> 
     <groupId>uk.ac.gate</groupId> 
     <artifactId>gate-compiler-jdt</artifactId> 
     <version>4.3.2-P20140317-1600</version> 
    </dependency> 

    <dependency> 
     <groupId>com.thoughtworks.xstream</groupId> 
     <artifactId>xstream</artifactId> 
     <version>1.4.8</version> 
    </dependency> 

    <dependency> 
     <groupId>jdk.tools</groupId> 
     <artifactId>jdk.tools</artifactId> 
     <version>${jdk.version}</version> 
     <scope>system</scope> 
     <systemPath>${java.home}/../lib/tools.jar</systemPath> 
    </dependency> 

    <dependency> 
     <groupId>org.jsoup</groupId> 
     <artifactId>jsoup</artifactId> 
     <version>1.8.3</version> 
    </dependency> 
    <dependency> 
     <groupId>com.scryAnalytics</groupId> 
     <artifactId>NLPGeneric</artifactId> 
     <version>1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>NER</groupId> 
     <artifactId>NER</artifactId> 
     <version>1.2</version> 
    </dependency> 

</dependencies> 

    <build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.3</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.5.5</version> 
      <configuration> 
       <finalName>NLPAnnotationController</finalName> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
       <archive> 
        <manifest> 
         <mainClass>com.scryAnalytics.NLPAnnotationController.GateNLPJob</mainClass> 
        </manifest> 
       </archive> 
      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
    <resources> 
     <resource> 
      <directory>conf</directory> 
     </resource> 
    </resources> 
</build> 

,當我運行它,我得到如下所示的錯誤。

java -jar target/NLPAnnotationController-jar-with-dependencies.jar -inputTable posts -outputTable posts -batchId 1 
Error: Invalid or corrupt jarfile target/NLPAnnotationController-jar-with-dependencies.jar 
+1

當你做一個簡單的'罐子電視臺說,jar'會發生什麼? – GhostCat

+0

* 「 com.scryAnalytics.NLPAnnotationController.GateNLPJob」 *是'NLPAnnotationController'類或一個包? –

+0

'jar電視那個罐子'繼續執行。不來停止 – wadhwasahil

回答

0

正如在評論中建議的那樣,仔細檢查JAR文件是否真的使用jar tv <filename.jar>損壞。

有腐敗的JAR文件幾個常見原因:

前三解釋是不太可能在你的情況,由於種種原因。這留下了一個Maven插件的問題。其中一個Q &正如我發現,這是在maven-assembly-plugin 2.5版中修復的。但是你似乎在使用更高版本。所以也許這畢竟不是問題。

總之:

  • 檢查您是否使用Java 7或更高版本的JRE或JDK您的構建執行平臺。
  • 嘗試在你的POM更新的maven組件插件的版本到最新的可用。
+0

因爲我使用make-assembly插件,所以如何解決上一個問題? – wadhwasahil

+0

查看更新..... –

+0

就Java和assembly插件而言,已嘗試更新後者,但錯誤仍然存​​在。 – wadhwasahil