title: java.lang.NoSuchMethodError: org.bouncycastle.asn1.DERSequence.<init>(Lorg/bouncycastle/asn1/DEREncodableVector;)V
body: <p>I've got an error when I try to get a TimeStamp response. The piece of code that I use is:</p>
  
  <pre><code>PdfPKCS7 sgn = new PdfPKCS7(pk, chain, null, "SHA256", null, false);
          InputStream data = sap.getRangeStream();
          MessageDigest messageDigest = MessageDigest.getInstance("SHA256",
                  "BC");
          byte buf[] = new byte[8192];
          int n;
          while ((n = data.read(buf)) &gt; 0) {
              messageDigest.update(buf, 0, n);
          }
          byte hash[] = messageDigest.digest();
          Calendar cal = Calendar.getInstance();
          byte[] ocsp = null;
  
          byte sh[] = sgn.getAuthenticatedAttributeBytes(hash, cal, ocsp);
          sgn.update(sh, 0, sh.length);
          byte[] encodedSig = sgn.getEncodedPKCS7(hash, cal, tsc, ocsp);
          System.out.println("contentEstimated: " + (contentEstimated + 2));
          System.out.println("encodedSig.length: " + encodedSig.length);
  </code></pre>
  
  <p>The error appears on the line:
      byte sh[] = sgn.getAuthenticatedAttributeBytes(hash, cal, ocsp);</p>
  
  <p>The error is:</p>
  
  <pre><code>org.alfresco.error.AlfrescoRuntimeException: Exception in Transaction.
          at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:404)
          at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
          at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:127)
          at org.alfresco.web.bean.dialog.DialogManager.finish(DialogManager.java:534)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
          at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
          at javax.faces.component.UICommand.broadcast(UICommand.java:109)
          at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
          at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
          at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
          at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
          at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.NoSuchMethodError: org.bouncycastle.asn1.DERSequence.&lt;init&gt;(Lorg/bouncycastle/asn1/DEREncodableVector;)V
          at com.lowagie.text.pdf.PdfPKCS7.getAuthenticatedAttributeSet(Unknown Source)
          at com.lowagie.text.pdf.PdfPKCS7.getAuthenticatedAttributeBytes(Unknown Source)
          at org.alfresco.module.veritasCONTRATOS.model.service.EmisionContratoServiceImpl.firmaDocumentoTimestamp(EmisionContratoServiceImpl.java:366)
          at org.alfresco.module.veritasCONTRATOS.model.service.EmisionContratoServiceImpl.firmaContrato(EmisionContratoServiceImpl.java:164)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
          at com.sun.proxy.$Proxy69.firmaContrato(Unknown Source)
          at org.alfresco.module.veritasCONTRATOS.beans.AddEmConDialog.finishImpl(AddEmConDialog.java:111)
          at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:121)
          at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:118)
          at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
          ... 31 more
  </code></pre>
  
  <p>I show same errors like this (<a href="http://itext-general.2136553.n4.nabble.com/Nosuchmethod-error-for-bouncy-castle-td3492864.html" rel="nofollow">http://itext-general.2136553.n4.nabble.com/Nosuchmethod-error-for-bouncy-castle-td3492864.html</a>), but i can't do this working. 
  I know that the problem is with bouncycastle libaries. I try with this versions:</p>
  
  <ul>
  <li>bcprov-jdk15-1.46.jar</li>
  <li>bcmail-jdk15-1.46.jar</li>
  <li>itextpdf-5.1.2.jar</li>
  </ul>
  
  <p>And other verios of bcprov-jdk (16-146, 14-146, 15-137, 15-1.43).</p>
  
  <p>Anyone know what i am doin wrong??
  Thanks a lot in advance.</p>