2 Replies Latest reply on Feb 4, 2015 12:26 AM by valsaraj007

    java.lang.LinkageError: loader constraint violation error

    valsaraj007

      Hi,

       

      I am getting this error at runtime:

      java.lang.LinkageError: loader constraint violation: when resolving method "org.app.security.key.MyKeyRing.<init>(Lorg/app/security/key/MyPrivateKey;Lorg/app/security/key/MyPublicKey;[Ljava/security/cert/Certificate;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/app/security/auth/KeyLoginModule, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/app/security/key/MyKeyRing, have different Class objects for the type curity/key/MyPrivateKey;Lorg/app/security/key/MyPublicKey;[Ljava/security/cert/Certificate;)V used in the signature


      The classes starts with 'My' are created for the application and is inside the EAR file. There is a custom module in created in WildFly and the jar with these classes are available in that too.

       

      What may be the reason?

       

      Thanks!

        • 1. Re: java.lang.LinkageError: loader constraint violation error
          jameslivingston

          That error means you have more than one definition of the MyPrivateKey class (likely in both the module and the EAR), and the caller (KeyLoginModule) and the class being called (MyKeyRing) have different ones.

           

          Usually, you would want to remove the duplicated classes from the EAR, and use jboss-deployment-structure.xml to depend on the module.

          1 of 1 people found this helpful
          • 2. Re: java.lang.LinkageError: loader constraint violation error
            valsaraj007

            Thanks James!

             

            The problem was I have this class in a jar inside ear lib and the same jar was in the custom jboss module that I created.

             

            When I use only the module and remove the jar from ear lib, I am getting class not found error. So I removed dependency to this module (com.app.configuration) and it worked fine.

             

            jboss-deployment-structure.xml:

            <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

              <deployment>

              <dependencies>

                 <!--<module name="com.app.configuration"/>-->

              </dependencies>

              </deployment>

            </jboss-deployment-structure>