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? -


i have jboss server has ear file. ear file has war file. war file has jar file "server-artifact.jar". server's service endpoint in jar. class in jar file loads class dynamically perform action.

class<?> clazz = (class<?>) class.forname("com.test.testexternalaccess"); try {   testexternalaccessparent extclassobject = (testexternalaccessparent) clazz.newinstance();   extclassobject.sayhellotoexternalaccess(); } catch (instantiationexception | illegalaccessexception e) {   e.printstacktrace(); } 

the jar file contains "testexternalaccessparent" interface, part of war file too. class "testexternalaccess" concrete class meant pluggable unit server. in order achieve this, created jboss module , put in modules folder (how?):

<module xmlns="urn:jboss:module:1.1" name="com.test">   <resources>     <resource-root path="externallibrary-0.0.1-snapshot.jar"/>   </resources> </module> 

i edited jboss-deployment-structure.xml , added dependency <module name="com.test" /> start server , run it. following exception when dynamic loading of class happens : java.lang.classnotfoundexception: com.test.testexternalaccess [module "deployment.myservice-ear.ear:main" service module loader]

some things have tried: 1) tried loading class external module not implement interface in jar file of main ear file , works fine. 2) changed module include jar file contains interface.

<module xmlns="urn:jboss:module:1.1" name="com.test">   <resources>     <resource-root path="externallibrary-0.0.1-snapshot.jar"/>     <resource-root path="externalparentlibrary-0.0.1-snapshot.jar"/>   </resources> </module> 

that works fine too. 3) added following dependency module:

<dependencies>   <module name="deployment.myservice-ear.ear"/> </dependencies> 

that not work.

the classloader loaded ear uses classloader load external module , gain access classes in module. classes in external module cannot seem able access jars in ear. how can make happen? want add external library modules has access classes in server's ear file classes.

i found solution problem. after playing around while jboss-deployment-structure.xml , modules, realized not possible make external module use or extend classes of ear/war. achieve goal, had make jar file @ external location loaded same class loader loads ear libraries. can achieved adding resource directly ear file 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 relative ear file in standalone/deployments folder. adding resource root way equivalent adding library lib folder of ear file. so, ensures external library loaded part of the main classloader loads ear framework libraries are.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -