8 Replies Latest reply on Mar 1, 2017 10:26 PM by bala260594

    Class Loading issue when deploying Ear file.

    bala260594

      The ear file is deployed successfully but the main.war file couldn't able to access classes form main.jar

      Plugins.ear

      |

      |--a.jar

      |--b.jar

      |--c.jar

      |--d.jar

      |--main.jar

      |--main.war

       

      The main.war need to access the classes in the main.jar, the main.jar is dependent on a.jar, b.jar, c.jar, d.jar

       

      application.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">

       

             <application-name>Plugins</application-name>

             <initialize-in-order>true</initialize-in-order>

              <module>

                  <ejb>main.jar</ejb>

             </module>

             <module>

                 <web>

                       <web-uri>main.war</web-uri>

                       <context-root>/main</context-root>

                  </web>

             </module>

      </application>

       

      jboss-deployment-structure.xml

      <jboss-deployment-structure>

           <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

           <deployment>

                <exclusions>

                     <module name="deployment.Plugins.ear.a.jar" />

                     <module name="deployment.Plugins.ear.b.jar" />

                     <module name="deployment.Plugins.ear.c.jar" />

                     <module name="deployment.Plugins.ear.d.jar" />

                     <module name="deployment.Plugins.ear.main.jar" />

               </exclusions>

                <dependencies>

                     <module name="deployment.Plugins.ear.main.jar" export="true" />

                </dependencies>

           </deployment>

           <sub-deployment name="testwebapp.war">

                <dependencies>

                     <module name="deployment.Plugins.ear.a.jar"/>

                     <module name="deployment.Plugins.ear.b.jar"/>

                     <module name="deployment.Plugins.ear.c.jar"/>

                     <module name="deployment.Plugins.ear.d.jar" />

                     <module name="deployment.Plugins.ear.main.jar" />

                </dependencies>

           </sub-deployment>

      </jboss-deployment-structure>

       

      I suspect the main.jar is deploying in different classloader and main.war is deployed in other classloader, this ear file is deployed successfully in jboss 6, I encountered this issues from jboss 7 because of module classloading mechanism. Kindly help me out to solve this issue, Thanks in advance

        • 1. Re: Class Loading issue when deploying Ear file.
          lafr

          I this case you not need jboss-deployment-structure.xml at all.  ear-subdeployments-isolated is false per default and all else is obsolete.

          Simply put a.jar, b.jar, c.jar and d.jar into lib folder of ear to make them accessible for main.jar and main.war.

          See also Class Loading in WildFly - WildFly 8 - Project Documentation Editor for more details.

          1 of 1 people found this helpful
          • 2. Re: Class Loading issue when deploying Ear file.
            bala260594

            Thanks for the comment, but still problem is not resolved even when i move all a.jar, b.jar, c.jar and d.jar in to lib folder of ear.

            The main.war couldn't able to access the classes available in main.jar. We suspect the main.jar is loading in a different class loader and main.war is loading in different class loader.

            • 3. Re: Class Loading issue when deploying Ear file.
              lafr

              This would be the case for ear-subdeployments-isolated = true, but not when set to false (default).

               

              Which JBoss AS / Wildfly version you're using? JBoss AS 7? You might take into account to directly go to Wildfly 10.1., the latest AS version.

              Show us the stacktrace you get.

              When do you see your problem, during deployment or later when you access your ear.war-file?

               

              Did you remove jboss-deployment-structure.xml from ear?

              Try to remove <initialize-in-order>true</initialize-in-order> from your application.xml.

               

              • 4. Re: Class Loading issue when deploying Ear file.
                bala260594

                Thanks Frank Langelage, we are using JBoss 7 (Our ear file is working fine till jboss 6, since the classloader is not module based class loading)

                It is getting deployed successfully but the main.war could not able to access class from the main.jar in this case and the main.jar has dependency on a.jar, b.jar, c.jar, d.jar.

                The problem occurs when main.war trying to access the class from main.jar.

                Yes, we removed jboss-deployment-structure.xml from ear.

                Even we are tried with removing <initialize-in-order>true</initialize-in-order> from application.xml, but the problem still persist.

                 

                As per you guidance we created the ear file, it will look as follow.

                 

                Plugins.ear

                |

                |--lib

                |      |--a.jar

                |      |--b.jar

                |      |--c.jar

                |      |--d.jar

                |--main.jar

                |--main.war

                 

                application.xml

                 

                <?xml version="1.0" encoding="UTF-8"?>

                <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                  version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">

                 

                       <application-name>Plugins</application-name>

                        <module>

                            <ejb>main.jar</ejb>

                       </module>

                       <module>

                           <web>

                                 <web-uri>main.war</web-uri>

                                 <context-root>/main</context-root>

                            </web>

                       </module>

                    <library-directory>lib</library-directory>

                </application>

                • 5. Re: Class Loading issue when deploying Ear file.
                  lafr

                  I have no clue why this setup does not work for you.

                  We have a very similar setup with a couple of ejb modules containing session and entity beans.

                  Another couple of web modules providing webservices using the session beans of the ejb-modules.

                  Both types are in the root directory of the ear file.

                  Additionally a couple of third party libraries in the lib folder of the ear.

                  And application.xml is just like yours.

                  • 6. Re: Class Loading issue when deploying Ear file.
                    bala260594

                    Can you share any simple example, so that it will be useful for us to solving this issue.

                    • 7. Re: Class Loading issue when deploying Ear file.
                      lafr

                      No, I can't.

                      But if you prepare a small project to reproduce your problem I could take a look at it.

                      • 8. Re: Class Loading issue when deploying Ear file.
                        bala260594

                        ok, we will create a small project and share to as soon as possible.