我用Maven [1]创建了一个jar文件,最后创建了一个名为medusa-java-jar-with-dependencies.jar
的jar文件。当我尝试提取文件的内容时,我收到此错误[2]。为什么我会收到此错误?这是pom.xml
中的问题吗?
[1] Maven配置
<plugin>
<!-- create one fat jar -->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.version}</version>
<configuration>
<excludes>
<exclude>**/log4j.properties</exclude>
<exclude>src/main/java/org/apache/hadoop/mapred/examples/Teste.java</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.apache.hadoop.mapred.examples.ExampleDriver</mainClass>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
解压缩jar文件时出现[2]错误
$ jar xf medusa-java-jar-with-dependencies.jar
java.io.FileNotFoundException: META-INF (Is a directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at sun.tools.jar.Main.copy(Main.java:909)
at sun.tools.jar.Main.extractFile(Main.java:1069)
at sun.tools.jar.Main.extract(Main.java:981)
at sun.tools.jar.Main.run(Main.java:311)
at sun.tools.jar.Main.main(Main.java:1288)
答案 0 :(得分:0)
我找到了解决方案。因为我想使用MapReduce,所以我不应该构建一个包含所有依赖项的胖jar,但是我应该将jar放在$ HADOOP_MAPREDUCE libs目录中。我做到了,它奏效了。
这link帮助了我。