【问题标题】:In java runtime, class not found exception在java运行时,找不到类异常
【发布时间】:2017-05-28 19:50:16
【问题描述】:

我正在构建 jar,并且在我的 .war 中使用这个 jar。当我运行程序时,出现以下异常。但是在那个 jar 文件中,那个特定的类就在那里。

Error: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class com.itc.zeas.custominputformat.CustomTextInputFormat not found
  at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2195) 
  at org.apache.hadoop.mapreduce.task.JobContextImpl.getInputFormatClass(JobContextImpl.java:174) 
  at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:749) 
  at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) 
  at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168) 
  at java.security.AccessController.doPrivileged(Native Method) 
  at 

【问题讨论】:

    标签: java mapreduce


    【解决方案1】:

    快速搜索使this 向上。

    您的类路径已损坏(这是 Java 世界中非常常见的问题)。

    根据您启动应用程序的方式,您需要修改 -cp 的参数、MANIFEST.MF 中的 Class-Path 条目或磁盘布局。

    也许您应该发布更多信息?你用什么工具来开发程序,编译时用了哪些参数等等。

    【讨论】:

    • 在同一个 jar 中,另一个类文件也在同一个包中工作。但是找不到这个CustomTextInputFormat.class
    • 你确定你正确地引用了这个类吗?你能检查一下这个类是否真的存在于com.itc.zeas.custominputformat.CustomTextInputFormat吗?
    • 是的,该类完全位于同一路径中。我也使用完全限定的类名。
    • 嗯...也许看看this问题。你能像这样运行你的程序吗:java -classpath thisJar.jar your.package.Main
    • 我正在使用 mvn clean install commad 在命令提示符下构建我的 jar,稍后通过 winSCP 我将我的 jar 放在 tomcat webapps lib 文件夹中,并且我正在启动我的服务器
    猜你喜欢
    • 2014-06-13
    • 2012-07-08
    • 2018-03-11
    • 1970-01-01
    • 2017-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多