1 Reply Latest reply on Oct 4, 2018 3:17 AM by Saurabh Shriramwar

    How to resolve java.lang.LinkageError org.bouncycastle.mail.smime.SMIMESignedGenerator.generate(Ljavax/mail/internet/MimeBodyPart;)

    Aarij Siddiqui Newbie

      Hi,

       

      I am using Bouncycastle (bcmail, bcprov, bcpkix) 1.57 in combination with Jboss EAP 6.4 (jboss-AS 7.5) and Java 1.8.

       

      I get a Linkage error with the following stacktrace:

       

      Caused by: java.lang.LinkageError:

      loader constraint violation: when resolving method "org.bouncycastle.mail.smime.SMIMESignedGenerator.generate(Ljavax/mail/internet/MimeBodyPart;)Ljavax/mail/internet/MimeMultipart;"

       

      the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, de/deutschepost/paket/mkp/transformation/SMIMEPreparator,

      and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the method's defining class, org/bouncycastle/mail/smime/SMIMESignedGenerator,

      have different Class objects for the type javax/mail/internet/MimeBodyPart used in the signature

       

      As far as my understanding goes there must be a duplicate or a conflict in  library versions somewhere in the hierarchy, but unfortunately I can't find any.

      Here is the list of all the dependencies that are present in the classpath at runtime:

       

      activation-1.1.jar

      activemq-broker-5.11.0.jar

      activemq-client-5.11.0.jar

      activemq-jms-pool-5.11.0.jar

      activemq-openwire-legacy-5.11.0.jar

      activemq-pool-5.11.0.jar

      antlr-2.7.7.jar

      aqapi-11.2.0.3-1.jar

      asm-5.0.4.jar

      aspectjrt-1.6.1.jar

      aspectjweaver-1.8.9.jar

      c3p0-0.9.5.2.jar

      camel-core-2.18.4.jar

      camel-cxf-2.18.4.jar

      camel-cxf-transport-2.18.4.jar

      camel-ftp-2.18.4.jar

      camel-http-2.18.4.jar

      camel-http-common-2.18.4.jar

      camel-jaxb-2.18.4.jar

      camel-jetty-2.18.4.jar

      camel-jetty9-2.18.4.jar

      camel-jetty-common-2.18.4.jar

      camel-jms-2.18.4.jar

      camel-mail-2.18.4.jar

      camel-mail-patch-2.10-senacor-3-SNAPSHOT.jar

      camel-ognl-2.18.4.jar

      camel-quartz2-2.18.4.jar

      camel-spring-2.18.4.jar

      cglib-nodep-2.1_3.jar

      classmate-1.3.0.jar

      commons-codec-1.4.jar

      commons-collections-3.2.1.jar

      commons-httpclient-3.1.jar

      commons-io-1.4.jar

      commons-lang-2.4.jar

      commons-lang3-3.3.2.jar

      commons-logging-1.0.4.jar

      commons-net-3.3.jar

      commons-pool-1.5.6.jar

      core-7.0.0-SNAPSHOT.jar

      cryptacular-1.0.jar

      cxf-core-3.1.12.jar

      cxf-rt-bindings-soap-3.1.12.jar

      cxf-rt-bindings-xml-3.1.12.jar

      cxf-rt-databinding-jaxb-3.1.12.jar

      cxf-rt-frontend-jaxrs-3.1.12.jar

      cxf-rt-frontend-jaxws-3.1.12.jar

      cxf-rt-frontend-simple-3.1.12.jar

      cxf-rt-rs-client-3.1.11.jar

      cxf-rt-rs-security-oauth-3.1.11.jar

      cxf-rt-security-3.1.12.jar

      cxf-rt-security-saml-3.1.12.jar

      cxf-rt-transports-http-3.1.12.jar

      cxf-rt-ws-addr-3.1.12.jar

      cxf-rt-wsdl-3.1.12.jar

      cxf-rt-ws-policy-3.1.12.jar

      cxf-rt-ws-security-3.1.12.jar

      dms-11.2.0.3-1.jar

      dom4j-1.6.1.jar

      dsn-1.5.5.jar

      ehcache-2.10.3.jar

      ehcache-core-2.5.7.jar

      geronimo-j2ee-management_1.1_spec-1.0.1.jar

      geronimo-jms_1.1_spec-1.1.1.jar

      geronimo-jta_1.0.1B_spec-1.0.1.jar

      gson-2.7.jar

      guava-18.0.jar

      h2-1.3.173.jar

      hamcrest-all-1.3.jar

      hamcrest-core-1.3.jar

      hawtbuf-1.11.jar

      hibernate-c3p0-5.2.10.Final.jar

      hibernate-commons-annotations-5.0.1.Final.jar

      hibernate-core-5.2.10.Final.jar

      hibernate-ehcache-5.2.10.Final.jar

      hibernate-envers-5.2.10.Final.jar

      hibernate-jpa-2.1-api-1.0.0.Final.jar

      hibernate-validator-4.2.0.Final.jar

      httpclient-4.5.3.jar

      httpcore-4.4.6.jar

      httpmime-4.5.3.jar

      itext-2.1.7.jar

      jandex-2.0.3.Final.jar

      jasypt-1.9.2.jar

      javassist-3.20.0-GA.jar

      java-support-7.1.1.jar

      javax.annotation-api-1.2.jar

      javax.inject-1.jar

      javax.mail-1.5.5.jar

      javax.mail-api-1.5.5.jar

      javax.servlet-api-3.1.0.jar

      javax.ws.rs-api-2.0.1.jar

      jaxb2-basics-runtime-0.6.3.jar

      jaxb-api-2.2.11.jar

      jaxb-core-2.2.11.jar

      jaxb-impl-2.2.11.jar

      jboss-logging-3.3.0.Final.jar

      jboss-transaction-api_1.2_spec-1.0.1.Final.jar

      jettison-1.3.7.jar

      jetty-client-9.2.21.v20170120.jar

      jetty-continuation-9.2.21.v20170120.jar

      jetty-http-9.2.21.v20170120.jar

      jetty-io-9.2.21.v20170120.jar

      jetty-jmx-9.2.21.v20170120.jar

      jetty-security-9.2.21.v20170120.jar

      jetty-server-9.2.21.v20170120.jar

      jetty-servlet-9.2.21.v20170120.jar

      jetty-servlets-9.2.21.v20170120.jar

      jetty-util-9.2.21.v20170120.jar

      jms-1.1.jar

      joda-time-2.3.jar

      jsch-0.1.54.jar

      jsmpp-2.1.0.jar

      json-simple-1.1.1.jar

      jsr250-api-1.0.jar

      jta-1.1.jar

      jutf7-1.0.0.jar

      mchange-commons-java-0.2.11.jar

      neethi-3.0.3.jar

      netty-all-4.0.26.Final.jar

      oauth-20100527.jar

      oauth-provider-20100527.jar

      ognl-3.1.10.jar

      ojdbc6-11.2.0.4.0.jar

      opensaml-core-3.1.1.jar

      opensaml-profile-api-3.1.1.jar

      opensaml-saml-api-3.1.1.jar

      opensaml-saml-impl-3.1.1.jar

      opensaml-security-api-3.1.1.jar

      opensaml-security-impl-3.1.1.jar

      opensaml-soap-api-3.1.1.jar

      opensaml-xacml-api-3.1.1.jar

      opensaml-xacml-impl-3.1.1.jar

      opensaml-xacml-saml-api-3.1.1.jar

      opensaml-xacml-saml-impl-3.1.1.jar

      opensaml-xmlsec-api-3.1.1.jar

      opensaml-xmlsec-impl-3.1.1.jar

      optivo-3.0.0-SNAPSHOT.jar

      oro-2.0.8.jar

      pushy-0.4.3.jar

      quartz-2.2.3.jar

      slf4j-api-1.7.5.jar

      spring-aop-4.3.8.RELEASE.jar

      spring-aspects-4.3.8.RELEASE.jar

      spring-beans-4.3.8.RELEASE.jar

      spring-context-4.3.8.RELEASE.jar

      spring-context-support-4.3.8.RELEASE.jar

      spring-core-4.3.8.RELEASE.jar

      spring-data-jdbc-core-1.0.0.RELEASE.jar

      spring-data-oracle-1.0.0.RELEASE.jar

      spring-expression-4.3.8.RELEASE.jar

      spring-jdbc-4.3.8.RELEASE.jar

      spring-jms-4.3.8.RELEASE.jar

      spring-messaging-4.3.8.RELEASE.jar

      spring-orm-4.3.8.RELEASE.jar

      spring-retry-1.0.0.RELEASE.jar

      spring-tx-4.3.8.RELEASE.jar

      spring-web-4.3.8.RELEASE.jar

      stax2-api-3.1.4.jar

      stax-api-1.0.1.jar

      ucp-11.2.0.4.0.jar

      validation-api-1.0.0.GA.jar

      velocity-1.6.2.jar

      woodstox-core-asl-4.4.1.jar

      wsdl4j-1.6.3.jar

      wss4j-bindings-2.1.10.jar

      wss4j-policy-2.1.10.jar

      wss4j-ws-security-common-2.1.10.jar

      wss4j-ws-security-dom-2.1.10.jar

      wss4j-ws-security-policy-stax-2.1.10.jar

      wss4j-ws-security-stax-2.1.10.jar

      xbean-spring-3.5.jar

      xml-apis-1.3.04.jar

      xmlpull-1.1.3.1.jar

      xml-resolver-1.2.jar

      xmlschema-core-2.2.2.jar

      xmlsec-2.0.8.jar

      xpp3_min-1.1.4c.jar

      xstream-1.4.5.jar

      xstream-hibernate-1.4.5.jar

       

      Apart from these I have an explicit dependency to Bouncycastle module (I added the module myself in jboss modules). The configuration file module.xml is as follows:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.1" name="org.bouncycastle">

        <resources>
             <resource-root path="bcmail-jdk15on-1.57.jar"/>
             <resource-root path="bcprov-jdk15on-1.57.jar"/>
             <resource-root path="bcpkix-jdk15on-1.57.jar"/>
        </resources>
        <dependencies>
             <module name="javax.api"/>
             <module name="org.jboss.logging"/>
             <module name="org.jboss.modules"/>
             <module name="javax.activation.api" />
             <module name="javax.mail.api"/>
        </dependencies>
      </module>

       

       

      I would be glad if anyone can help me out here.

       

      Thanks.