hipi测试运行失败

ktecyv1j  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(550)

我一直在尝试遵循clouderavm(cdh-5.4.2)的教程,但是在尝试运行构建的jar来计算像素数时遇到了一个异常。
构建本身成功:

[cloudera@quickstart helloWorld]$ gradle jar
:core:compileJava UP-TO-DATE
:core:processResources UP-TO-DATE
:core:classes UP-TO-DATE
:core:jar UP-TO-DATE
:examples:helloWorld:compileJava UP-TO-DATE
:examples:helloWorld:processResources UP-TO-DATE
:examples:helloWorld:classes UP-TO-DATE
:examples:helloWorld:jar

BUILD SUCCESSFUL

Total time: 18.436 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.7/userguide/gradle_daemon.html

但是执行jar会引发以下错误:

[cloudera@quickstart helloWorld]$ hadoop jar build/libs/helloWorld.jar examples/sampleNew.hib sampleimages_average
Exception in thread "main" java.lang.NoClassDefFoundError: org/hipi/imagebundle/mapreduce/HibInputFormat
    at org.hipi.examples.HelloWorld.run(HelloWorld.java:106)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
    at org.hipi.examples.HelloWorld.main(HelloWorld.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.ClassNotFoundException: org.hipi.imagebundle.mapreduce.HibInputFormat
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 10 more

在同一根hipi父项目的示例文件夹中,此子项目的my build.gradle如下所示:

jar {
  manifest {
    attributes("Main-Class": "org.hipi.examples.HelloWorld")

  }

  dependencies{
    compile project(':core')
  }
}

有人能帮我什么我错过了,如何使它运行?

java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

由于我是gradle的新手,所以我无法在eclipse下配置hipi以用于其他项目,所以我尝试只运行终端。有人能帮我吗?
注意:我的网络访问受到限制,因此在我的系统中几乎没有下载权限。

vnjpjtjt

vnjpjtjt1#

我已经解决了这个问题,通过gradle将jar中的所有文件包括在内,如下所示

jar {
  manifest {
    attributes("Main-Class": "org.hipi.examples.HelloWorld")
  }

  dependencies{
    compile project(':core')
  }

 from {
    configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}

相关问题