我一直在尝试按照cloudera VM (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 父项目的示例文件夹中的这个子项目的 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 以便在其他项目中使用,所以我只尝试通过终端运行。任何人都可以帮助我吗?
注意:我的互联网访问受到限制,因此我的系统几乎没有下载权限。