[英]ClassNotFoundException: org.apache.pdfbox.pdmodel.PDDocument
I am getting below error during compilation. 编译期间出现错误。 I am using Eclipse IDE & working on Ubuntu.
我正在使用Eclipse IDE并在Ubuntu上工作。 I have added the following jar files in the build path 1) pdfbox 1.8.13 & All its dependencies 2) Commons-logging-1.2 .
我在构建路径中添加了以下jar文件1)pdfbox 1.8.13及其所有依赖项2)Commons-logging-1.2。
Please let me know why there is error when the class is in the jar file ? 请让我知道为什么该类在jar文件中时会出错?
Error: java.lang.ClassNotFoundException: org.apache.pdfbox.pdmodel.PDDocument
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.hadoopexpert.PdfRecordReader.initialize(PdfRecordReader.java:41)
at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.initialize(MapTask.java:521)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:763)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:421)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
at org.apache.hadoop.mapred.Child.main(Child.java:249)
My query was resolved by doing following changes 通过执行以下更改解决了我的查询
1) Place the jar file of pdfbox in hadoop lib folder too.(make library jar available to hadoop at runtime). 1)将pdfbox的jar文件也放置在hadoop lib文件夹中(使库jar在运行时可用于hadoop)。
2) Restart hadoop cluster. 2)重新启动hadoop集群。
Or 要么
1) Make sure that your pdfbox library is available to hadoop by placing it in distributed cache. 1)将您的pdfbox库放置在分布式缓存中,以确保其可用于hadoop。
https://stackoverflow.com/a/34179783/8956991 https://stackoverflow.com/a/34179783/8956991
You have the class on the build path, so it compiles, but apparently you don't have it in the classpath of the running binary, which is why it doesn't run. 您将类放在构建路径上,因此可以进行编译,但是显然您没有在正在运行的二进制文件的类路径中使用它,这就是为什么它不运行的原因。 Make sure that your application's classpath includes all the JARs that you have added (or use some build system such as Maven or Gradle which automates that for you).
确保您的应用程序的类路径包含您添加的所有JAR(或使用某些构建系统,例如Maven或Gradle,它们会自动为您提供自动化)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.