4 Replies Latest reply on Mar 5, 2015 8:29 AM by Siva Masilamani

    JBoss custom module java.lang.LinkageError: loader constraint violation: when resolving interface method

    Siva Masilamani Newbie

      Hi

      We are facing issue deploying our ear in JBOSS EAP 6.0. We are getting Linkage error by one of our custom module.

      Our ear uses lots of 3rd party jars,api jars produced by our company and it contains 3 web and 3 ejb modules and classes common to these modules are in ear/lib folder.

       

      Ear

        lib/common classes

        EJB1

        EJB2

        EJB3

        WEB1

        WEB2

        WEB3

       

      For all the 3rd party jars we created a module name com.company.lib and our app uses 10 api jars produced by our organization and we have modules created for each one of them. Since some of the apis depend on other and also need 3rd party jars,we add com.company.lib and module name  as dependencies to the corresponding module.xml file

       

      E.g. API1 ,API2,API3

      Our classes from EAR depends on API1,2,3 and 3rd party jars

      API1 depends on 3rd party jar and API2 and API3

      API2 depeonds on 3rd party jar and API3 etc

      Similarly we define dependencies for each of these api in their module.xml files

       

      API1 is the only module that depends on API2

       

      our Jboss-Struture xml file looks like below

       

       

      <jboss-deployment-structure>

        <deployment>

        <dependencies>

        <module name="com.company.lib" export="true"/>

       

        <module name="com.api1.lib" export="true"/>

        <module name="com.api2.lib" export="true"/>

        <module name="com.api3.lib" export="true"/>

        <module name="com.api4.lib" export="true"/>

        <module name="com.api5.lib" export="true"/>

        <module name="com.api6.lib" export="true"/>

        <module name="com.api7.lib" export="true"/>

        <module name="com.api8.lib" export="true"/>

        <module name="com.api9.lib" export="true"/>

        <module name="com.api10.lib" export="true"/>

        </dependencies>

        </deployment>

      </jboss-deployment-structure>

       

       

      Sample api's module.xml

      <module xmlns="urn:jboss:module:1.1" name="com.api1.lib">

        <resources>

        <resource-root path="api1.jar"/>

        </resources>

        <dependencies>

        <module name="com.company.lib"/>

        <module name="com.api2.lib"/>

        <module name="com.api3.lib"/>

        </dependencies>

      </module>

       

       

      <module xmlns="urn:jboss:module:1.1" name="com.api2.lib">

        <resources>

        <resource-root path="api2.jar"/>

        </resources>

        <dependencies>

        <module name="com.company.lib"/>

        <module name="com.api3.lib"/>

        </dependencies>

      </module>

       

      <module xmlns="urn:jboss:module:1.1" name="com.api3.lib">

        <resources>

        <resource-root path="api3.jar"/>

        </resources>

        <dependencies>

        <module name="com.company.lib"/>

        </dependencies>

      </module>

       

      If we remove export=true in jboss struture xml ,then deployment fails to find any of the classes from api modules,but if we add export =true,the application installs fine when throws Linkage error as below when one of the classes in ear/lib is being called

       

      Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "com.api2.service.remote.API2.getUserName(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/api3/security/util/UserNameTokens;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, com/company/service/UserSecurityUtil, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, com/api2/service/remote/API2, have different Class objects for the type onInteractionServiceRMI used in the signature