1

I am getting below error during compilation. I am using Eclipse IDE & working on 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 .

Please let me know why there is error when the class is in the jar file ?

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)
1
  • Unrelated to the problem - if you're just starting with PDFBox, then use 2.0.8 and not the 1.8 versions. Commented Nov 17, 2017 at 13:38

2 Answers 2

1

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).

2) Restart hadoop cluster.

Or

1) Make sure that your pdfbox library is available to hadoop by placing it in distributed cache.

https://stackoverflow.com/a/34179783/8956991

Sign up to request clarification or add additional context in comments.

Comments

0

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).

2 Comments

Thanks for the information. I am using Eclipse IDE & have the jars in java build path of particular project. Can you guide me if there is anything else i need to do
As Piotr wrote "... but apparently you don't have it in the classpath of the running binary". I don't use eclipse myself, but I've often heard that what builds doesn't run. see stackoverflow.com/questions/10383226/… stackoverflow.com/questions/2520821/… stackoverflow.com/questions/9282440/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.