Reputation: 21
I am using pdfbox 3.0 to load a PDF as follows (Eclipse IDE, java.runtime.version=17.0.4.1+1):
File pdfFile = new File("C:\\Users\SchroeT\\myPDF.pdf");
System.out.println("\n\nFile: " + pdfFile);
PDDocument doc = Loader.loadPDF(pdfFile);
I added the following jar files to the Modulepath under "Libraries" in Eclipse: fontbox-3.0.0-alpha3.jar pdfbox-3.0.0-alpha3.jar pdfbox-debugger-3.0.0-alpha3.jar pdfbox-tools-3.0.0-alpha3.jar preflight-3.0.0-alpha3.jar xmpbox-3.0.0-alpha3.jar
The following output points to a “ClassNotFoundException”
Please help
Console output in Eclipse:
File: C:\Users\SchroeT\myPDF.pdf
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at [email protected]/org.apache.pdfbox.pdfparser.BaseParser.(BaseParser.java:61) at [email protected]/org.apache.pdfbox.Loader.loadPDF(Loader.java:343) at [email protected]/org.apache.pdfbox.Loader.loadPDF(Loader.java:317) at [email protected]/org.apache.pdfbox.Loader.loadPDF(Loader.java:277) at [email protected]/org.apache.pdfbox.Loader.loadPDF(Loader.java:230) at geoscene/geoscene.MainClass.main(MainClass.java:161) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 6 more
Upvotes: 1
Views: 3037
Reputation: 21
I found a solution: I had to delete the module-info.java file. After that, I ran into further issues (could not find PDAnnotationMarkup). I removed all jar files mentioned above and only added the bigger pdfbox-app-3.0.0-alpha3.jar.
Upvotes: 1