java.lang.NoClassDefFoundError:无法初始化类com.itextpdf.text.pdf.security.CertificateInfo $ X500Name

时间:2014-05-28 05:52:50

标签: java pdf itext digital-signature

我正在尝试为我的pdf文档添加数字签名。运行代码

MakeSignature.signDetached(appearance,digest,es,chain, 
  null, null, null, 0, CryptoStandard.CMS);

我收到以下错误。请帮帮我。

ERROR [http-8080-Processor24] - Servlet.service() for servlet action threw exception
java.lang.NoClassDefFoundError: Could not initialize class com.itextpdf.text.pdf.security.CertificateInfo$X500Name
  at com.itextpdf.text.pdf.security.CertificateInfo.getSubjectFields(CertificateInfo.java:354)
  at com.itextpdf.text.pdf.PdfSignatureAppearance.getAppearance(PdfSignatureAppearance.java:832)
  at com.itextpdf.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance.java:1205)
  at com.itextpdf.text.pdf.security.MakeSignature.signDetached(MakeSignature.java:134)
  at ksrtc.eis.presentation.action.Signatures.signPdfFirstTime(Signatures.java:112)
  at ksrtc.eis.presentation.action.Signatures.main(Signatures.java:221)
  at ksrtc.eis.presentation.action.AttandanceAction.execute(AttandanceAction.java:95)
  at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
  at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
  at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
  at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
  at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
  at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
  at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
  at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
  at java.lang.Thread.run(Thread.java:701)

3 个答案:

答案 0 :(得分:1)

您将使用iTextPdf.jar进行此实施。请确保将此jar添加到类路径中。 如果您正在使用eclipse,要将jar添加到classpath,请执行以下操作: 右键单击项目 - > Java构建路径 - >图书馆 - >添加外部罐子

如果您遇到与任何其他依赖类文件相同的问题,也请执行该jar的上述步骤。做一个干净的建筑,你的问题应该解决。

答案 1 :(得分:0)

删除Apache-all Library set,它对我有用。

答案 2 :(得分:0)

我正在使用Eclipse编辑器在一个示例下载的应用程序上使用itext 5.X和bounty城堡库以及libs集中的apacheds-all-1.5.4.jar来锁定PDF文件。它在Eclipse中运行得非常好。然后我开始使用相同的示例应用程序和库来开发JDeveloper。但是找不到课堂和安全问题。

我正在玩它一整天而且无法弄明白。第二天早上我删除了apacheds-all-1.5.4.jar,应用程序运行得很好。希望能帮助到你 !