解决ES-Hadoop打包报错“Mkdirs failed to create /var/folders...”问题

一、报错问题

在mac下运行ES-Hadoop项目,报错如下:

Bee:eshadoop bee$ hadoop jar target/eshadoop-1.0-SNAPSHOT-jar-with-dependencies.jar /work/blog.json
Exception in thread "main" java.io.IOException: Mkdirs failed to create /var/folders/36/84ywbb7j5kx1jysq1zk9rlzh0000gn/T/hadoop-unjar965332053308521935/META-INF/license
        at org.apache.hadoop.util.RunJar.ensureDirectory(RunJar.java:128)
        at org.apache.hadoop.util.RunJar.unJar(RunJar.java:104)
        at org.apache.hadoop.util.RunJar.unJar(RunJar.java:81)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:209)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

这里写图片描述

二、解决

原因是:

zip -d target/eshadoop-1.0-SNAPSHOT-jar-with-dependencies.jar META-INF/LICENSE

附打包插件:

    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.tsinghua.HdfsToEs</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-shade-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>com.tsinghua.HdfsToEs</mainClass>
                </transformer>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer">
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

参考:https://stackoverflow.com/questions/10522835/hadoop-java-io-ioexception-mkdirs-failed-to-create-some-path

阅读更多

扫码向博主提问

中科院硕士_姚攀

博客专家

熟悉Lucene、ES、ELK
去开通我的Chat快问
版权声明:本文为博主原创文章,未经博主允许禁止转载(http://blog.csdn.net/napoay) https://blog.csdn.net/napoay/article/details/80390741
个人分类: Elasticsearch hadoop
所属专栏: Elasticsearch专栏
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭