-1

I am trying to add a digital signature for my pdf document.while running the code

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

I get the following error. please help me.

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)
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
user3679175
  • 1
  • 1
  • 2

3 Answers3

1

You would be using iTextPdf.jar for this implementation. Please make sure that this jar is added to your classpath. If you are using eclipse, to add jar to classpath do the following: Right click project -> Java build path -> Libraries -> Add external jars

If you are facing the same issue with any other dependant class files do the above steps for that jar as well. Do a clean built and your issue should be resolved.

Dinal
  • 661
  • 4
  • 9
  • +1 for the clean build. Chances are that you have more than one iText jar in your CLASSPATH. Start from scratch and your application will work. – Bruno Lowagie May 28 '14 at 07:01
  • this didn't solve the problem.when i first logged in after restarting the server i get the following error:Servlet.service() for servlet action threw exception java.lang.SecurityException: class "org.bouncycastle.asn1.ASN1ObjectIdentifier"'s signer information does not match signer information of other classes in the same package – user3679175 May 28 '14 at 07:08
  • Check the below link for this issue : http://stackoverflow.com/questions/2877262/java-securityexception-signer-information-does-not-match – Dinal May 28 '14 at 07:56
0

Remove Apache-all Library set and it worked for me.

  • 1
    Can you elaborate on how to do so? – EWit Aug 18 '14 at 14:31
  • I was working with Eclipse editor on a sample downloaded application to lock a PDF file using itext 5.X and bounty castle libraries and apacheds-all-1.5.4.jar in the set of libs. It was working absolutely fine in Eclipse. Then I started working on JDeveloper with the same sample application and libraries. But getting class not found and security issues.I was playing with it for a full day and couldn't figure it out. Then next day morning I removed apacheds-all-1.5.4.jar and the application ran just fine. Hope it helps ! – JavaBug Aug 19 '14 at 14:59
0

I was working with Eclipse editor on a sample downloaded application to lock a PDF file using itext 5.X and bounty castle libraries and apacheds-all-1.5.4.jar in the set of libs. It was working absolutely fine in Eclipse. Then I started working on JDeveloper with the same sample application and libraries. But getting class not found and security issues.

I was playing with it for a full day and couldn't figure it out. Next day morning I removed apacheds-all-1.5.4.jar and the application ran just fine. Hope it helps !