尝试使用pdfBox时出现.NoClassDefFoundError [英] .NoClassDefFoundError when trying to use pdfBox

查看:1450
本文介绍了尝试使用pdfBox时出现.NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用其中一个 PDFBox 示例来提取图像时,在运行时,它给出了以下异常:

when I try to use one of the PDFBox examples for extracting images, in the run time,it gives me the following exception:

   Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.apache.pdfbox.pdfparser.BaseParser.<clinit>(BaseParser.java:68)
    at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1218)
    at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1186)
    at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1111)
    at pdfboxtest.PdfBoxTest.extractImage(PdfBoxTest.java:69)
    at pdfboxtest.PdfBoxTest.main(PdfBoxTest.java:53)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more

这是发生异常的代码的一部分,在最后两行:

here is the part of the code that exception occurs, at the last two lines:

         String pdfFile = "pdf file path";
         File pdf=new  File(pdfFile);
         PDDocument document = null;
         document = PDDocument.loadNonSeq(pdf, null, password);
         document = PDDocument.load( pdfFile );


推荐答案

添加commons-logging-1.1.1.jar $你的lib目录中的b $ b或
jcl-over-slf4j-1.7.6.jar。

Add commons-logging-1.1.1.jar or jcl-over-slf4j-1.7.6.jar in your lib directory.

这篇关于尝试使用pdfBox时出现.NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆