3 Replies Latest reply on Sep 26, 2013 6:09 AM by Andrea Cacciatori

    Classloading issue in EAP 6.1 - JBoss 7.2

    Andrea Cacciatori Newbie

      Hi to all.



         I have a strange kind of problem.



      My application is simple structured like that:



                                                                  |--- WAR                                                     





      I put my specific application jar into lib directory of the EAR, and then i refer it into MANIFEST of WAR module.



      I have another jar in the lib directory of the WAR, this jar contains a servlet.



      When i start the server and full publish my application all is fine, but in the runtime phase when i call the entry point of my application i obtain a ClassNotFound error about this servlet. (maybe the servlet uses a class contained in my application jar, which that is contained in EAR lib)



      Instead, if i put the specific application jar into lib directory of the WAR togheter with the other jar (which one that contain the servlet) i don't obtain any kind of error (even at runtime).



      But i need to maintain my application jar into lib directory of the EAR.


      I don't have problems with other type of jar, maybe the problem in this case is related to the servlet? classloading isolation?don't know?:(



      Any suggestions? What can i do?


      I try multiple type of configuration about jboss-classloading.xml without success..



      PS: With another type of application server like websphere i don't have any problem and i can maintain the jar into EAR lib directory.



      Thanks in advance.




        • 1. Re: Classloading issue in EAP 6.1 - JBoss 7.2
          Andrea Cacciatori Newbie

          Assumed that: Each class will use it's own classloader to load other classes. So if ClassA.class references ClassB.class then ClassB needs to be on the classpath of the classloader of ClassA, or it's parents.



          If i add to manifest (of WAR) the classpath dependency about the jar into EAR/lib how is possible that the class into war doens't see class into EAR/lib?



          I'am going crazy...missing another type of setting?

          • 2. Re: Classloading issue in EAP 6.1 - JBoss 7.2
            jaikiran pai Master

            Placing the class in a jar within .ear/lib should make it available to all components in that .ear application including the nested war. So please post the entire exception stacktrace that you are seeing and also post the output of


            jar -tf yourear.ear

            • 3. Re: Classloading issue in EAP 6.1 - JBoss 7.2
              Andrea Cacciatori Newbie

              Follow the stacktrack as your request:


              {java.lang.NoClassDefFoundError: it/myapp/services/servlets/Dispatcher}|



              at it.myapp.services.contexts.ContextManager.configureSet(ContextManager.java:2972)}



              at it.myapp.services.servlets.Dispatcher.getSession(Dispatcher.java:1344)}



              at it.myapp.services.servlets.Dispatcher.service(Dispatcher.java:5139)}



              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)}



              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)}



              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)}



              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)}



              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)}



              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)}



              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)}



              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)}



              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)}



              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)}



              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)}



              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)}



              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)}



              at java.lang.Thread.run(Thread.java:722)}



              Caused by: java.lang.ClassNotFoundException: it.myapp.services.servlets.Dispatcher from [Module "deployment.MyEAR.ear:main" from Service Module Loader]}



              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196)}



              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444)}



              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432)}



              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374)}



              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119)}



              ... 17 more}


              the problem is propertly related to classloading visibility...it's very strange.


              Dispatcher is a servlet-class packed in a jar into WAR/lib, this class call another class (ContextManager) that is contained into a jar in EAR/lib.

              In the manifest of WAR/lib i have correctly added to classpath the jar into EAR/lib.

              Maybe the problem is the opposite, ie a class from EAR's jar seems cannot see servlet class into WAR...Is possibile to remove this limitation?