How can i add a jboss 7.1 module that contain classes that implements/extends from classes in the main ear file of the server?

后端 未结 1 427
长情又很酷
长情又很酷 2021-01-20 12:01

I have a JBoss server that has an ear file. My ear file has a war file. The war file has a jar file \"server-artifact.jar\". My server\'s service endpoint is in that jar. Th

相关标签:
1条回答
  • 2021-01-20 12:31

    I found a solution to my problem. After playing around for a while with the jboss-deployment-structure.xml and modules, i realized that it is not possible to make an external module use or extend classes of the ear/war. To achieve my goal, i had to make my jar file which is at an external location be loaded by the same class loader that loads the ear libraries. This can be achieved by adding a resource directly to the ear file as below(jboss-deployment-structure.xml):

    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
    <deployment>
        <dependencies>
            <module name="org.jboss.as.jmx"/>
            <module name="org.jboss.logmanager"/>
        </dependencies>
    <resources>
        <resource-root path="../../../../../../../../../externalLib/externalLibrary-0.0.1-SNAPSHOT.jar" /> 
    </resources>
    </deployment>
    
    <sub-deployment name="myservice.war">
    </sub-deployment>
    <sub-deployment name="admin.war">
    </sub-deployment>   
    

    The resource-root path is relative to the ear file in the standalone/deployments folder. Adding the resource root as this way is equivalent to adding the library to the lib folder of the ear file. So, this ensures that my external library is also loaded as part of the the main classloader that loads the ear where all my framework libraries are.

    0 讨论(0)
提交回复
热议问题