1 Reply Latest reply on Nov 24, 2015 7:38 AM by jaysensharma

    JBOSS AS7 Wildfly 8.x classloader issue

    vivekgade123

      I need to access a class inside a package named com.ex.tutorial at runtime which is there in the JAR name abc.jar which is inside deployed EAR named myexample.ear in ../wildfly/standalone/deployments folder.

      But when i'm doing this, the classloader is returning the path i.e ../wildfly/bin/content/myexample.ear/abc.jar/com.ex.tutorial...

       

      Please suggest what should be done to resolve this issue...

        • 1. Re: JBOSS AS7 Wildfly 8.x classloader issue
          jaysensharma

          Please explain the following:

           

          1). From which code/application are you trying to access the classes present in JAR "myexample.ear/abc.jar"

          2). Please post the code which you are using to access the classes present inside the "myexample.ear/abc.jar"




          Assuming that you have some other client application deployed on the same WildFly instance and that application wants to access the classes present inside "myexample.ear/abc.jar"

          If you really want to load a class which is present inside a separate EAR/JAR  from another code deployed on the same server you can try using the "jboss-deployment-structure.xml" file as following:


          For EAR put it inside the "ClientApp.ear/META-INF/jboss-deployment-structure.xml"   (If you have WAR as a client then  try "ClientWebApp.war/WEB-INF/jboss-deployment-structure.xml")

          <?xml version="1.0"?> 
          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
            <deployment> 
              <dependencies> 
                 <module name="deployment.myexample.ear.abc.jar"  export="true" />
              </dependencies> 
            </deployment> 
          </jboss-deployment-structure> 
          

           

          Then  the classes present inside your Client App (ClientApp.ear or ClientWebApp.war) can access the classes present inside the  "deployment.myexample.ear.abc.jar"

           

          Same thing can also be achieved using the "META-INF/MANIFEST.MF" following entry:

          Dependencies: deployment.myexample.ear.abc.jar
          

           

           

          https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly

           

          Regards

          Jay SenSharma