job jars fail on OS X due to case-insensitive name conflict on 'license'
本文解决的问题首先适用于如下人群:在mac上开发hadoop程序,并且适用maven来管理项目的广大程序猿们,如果你问题不适合该环境,可以绕道而行,当然如果你有兴趣阅读本文,欢迎。我想在mac上玩hadoop或者研究开发hadoop的果粉来说,碰见这个问题,一定让你很头大。用maven打的可执行jar包,在linux上运行的好好的,但是在mac上就是不行,并且报的错误如下:
Exception in thread "main" java.io.IOException: Mkdirs failed to create /Users/chengdedeng/work/hadoop-0.21.0/myspace/hadooptmp/hadoop-unjar5053508897247834450/license
看到这个错误之后你刚开始觉得很简单,难道没有权限,那告诉你吧,你的想法是错误的。
当然我的命令用的是hadoop jar ***.jar了,因为我打的是可执行的jar包,所以不需要输入后面的参数,这个不多说。为什么会出现这样的错误呢?首先得必须说一下hadoop jar的运行机制,他会自动解压jar包,然后执行你的main函数,解压的过程中不能创建license这个文件夹,因此出现问题。那是不是hadoop的问题呢?肯定不是,因为在linux服务器上可以运行,在mac上不能运行,说明hadoop不存在问题。所以只可能是maven打的jar包出现问题,不多说废话,直接上打可执行jar包的代码吧!
<!--打可执行的jar包,如果使用了IOC容器,需要下面的配置-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<!--woodstox includes a "LICENSE" file in its jar root that conflicts with the "license"
directory on case-insensitive file systems-->
<!--<filter>-->
<!--<artifact>org.codehaus.woodstox:wstx-lgpl</artifact>-->
<!--<excludes>-->
<!--<exclude>LICENSE</exclude>-->
<!--</excludes>-->
<!--</filter>-->
<!--remove signature files-->
<!--<filter>-->
<!--<artifact>*:*</artifact>-->
<!--<excludes>-->
<!--<exclude>META-INF/*.SF</exclude>-->
<!--<exclude>META-INF/*.DSA</exclude>-->
<!--<exclude>META-INF/*.RSA</exclude>-->
<!--<exclude>license/*</exclude>-->
<!--</excludes>-->
<!--</filter>-->
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.ddmap.hadoop.db.mapreduce.cityofuser.Main</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
碰见该问题是只需要放开我注销的那部分就ok了,如果还有问题,可以mail我。
邮箱:mapserver000@gmail.com
参考文章:https://issues.apache.org/jira/browse/MAHOUT-780
https://github.com/wpm/Hadoop-GATE/blob/master/pom.xml
页:
[1]