由于NoclassdefinitionFound,HIPI测试运行失败

时间:2015-10-26 15:53:00

标签: java hadoop cloudera-quickstart-vm hipi

我一直在尝试在cloudera VM(cdh-5.4.2)上关注the tutorial但是在尝试运行构建的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以便在其他项目中使用,所以我试图仅在终端上运行。也可以帮助我吗?

注意:我的互联网访问受限,因此我的系统几乎没有下载权限。

1 个答案:

答案 0 :(得分:0)

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

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

  dependencies{
    compile project(':core')
  }

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