5 Replies Latest reply on Sep 16, 2005 7:31 AM by G.Rajasekhar

    Yet another Class Loader problem - Please Help

    Manjula Jayaraman Newbie

      Hi All,

      For the first time, i wrote the MBean service. I'm using Commons Digester and run into class loader problem. My problem disappears if i remove $JBOSS_HOME/server/default/deploy/jbossweb-tomcat50.sar/commons-diggest.jar. But as soon as i remove, the tomcat throws the following exception. Please note that i get these problems only when i set "java2ParentDelegation" to true. I spent several hours reading various online posts, wiki pages and JBoss documentation. Actually, what i need was to have each of our service to have it's own version of certain libraries. And that's why i've defined our own class loader repository. In many of the posts, i saw other people having the same issue and they resolved it by removing the library in question from default/lib. But in my case, if i remove commons-diggest.jar from the jbossweb-tomcat50.sar folder, that service doesn't start any more. Could someone please throw some light on what is that i'm missing?

      Thanks for any insight into the problem!


      21:59:40,995 ERROR [BaseModelMBean] Error creating class java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
      21:59:40,998 ERROR [Tomcat5] Starting failed jboss.web:service=WebServer
      javax.management.NotCompliantMBeanException: Null MBeanInfo for jboss.web:type=server
       at org.jboss.mx.server.registry.BasicMBeanRegistry.registerMBean(BasicMBeanRegistry.java:208)
       at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1018)
       at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:304)
       at org.jboss.web.tomcat.tc5.Tomcat5.startService(Tomcat5.java:317)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
       at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:884)
       at $Proxy18.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:414)
       at org.jboss.system.ServiceController.start(ServiceController.java:436)
       at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:251)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:829)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:604)
       at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy8.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:304)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:478)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:884)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:414)
       at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:251)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:829)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:604)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:588)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy5.deploy(Unknown Source)
       at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:407)
       at org.jboss.system.server.ServerImpl.start(ServerImpl.java:311)
       at org.jboss.Main.boot(Main.java:145)
       at org.jboss.Main$1.run(Main.java:399)
       at java.lang.Thread.run(Thread.java:552)
      


      Here's how i've defined my MBean service:


      public interface DemoServiceMBean extends ServiceMBean {
      
      }
      
      public class DemoService extends ServiceMBeanSupport implements DemoServiceMBean {
      
       public void startService() throws Exception {
       StringBuffer test = new StringBuffer();
       Debug.displayClassInfo(DemoService.class, test);
       System.out.println("class info: " + test);
       URL u = Thread.currentThread().getContextClassLoader().getResource("config/digester_rules.xml");
       Digester digester = DigesterLoader.createDigester(u);
       digester.setUseContextClassLoader(true);
      
       InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("config/xml_for_digester.xml");
      
       digester.parse(inStream);
       inStream.close();
       }
      
      }


      Here's how my jboss-service.xml file looks:

      <server>
      
       <!-- Defines a separate ClassLoader for this service instance. -->
       <loader-repository>digesterloadertest.demoservice:loader=DemoServiceCL
       <!--
       Specifies that the classes in this classloader should not be shared with
       the global JBoss classloader & thus with other deployed archives.
       This allows multiple Hilo services to be deployed on the same JBoss server.
       -->
       <loader-repository-config>java2ParentDelegation=true</loader-repository-config>
       </loader-repository>
      
       <!-- Defines the attributes for the main Service MBean -->
       <mbean code="digesterloadertest.DemoService" name="digesterloadertest.demoservice:service=DemoService"/>
      </server>




        • 1. Re: Yet another Class Loader problem - Please Help
          G.Rajasekhar Newbie

          hi,

          If you are sure that the exception you are getting is due to tomcat, then putting the jar file in $TOMCAT_HOME/lib/. should work for you.

          Thanks
          G.Rajasekhar

          • 2. Re: Yet another Class Loader problem - Please Help
            Manjula Jayaraman Newbie

            Thanks for your response Rajasekhar.

            I assume you that you are saying $JBOSS_HOME/server/default/lib.

            If i put commons-digerter.jar here and also package it with my application, when i hot deploy my sar, i get the following exception. The first time i start JBoss server, my SAR gets deployed properly as tomcat is not yet deployed. But my requirement is that i want to have different versions of (commons) jars for my application which could be different from what Tomcat uses.

            Could someone please point out what is that i'm missing?

            Thanks again!

            11:11:04,679 WARN [ServiceController] Problem starting service digesterloadertest:service=DemoService
            java.lang.NoClassDefFoundError: org/apache/commons/digester/ObjectCreationFactory
             at org.apache.commons.digester.Digester.addFactoryCreate(Digester.java:2044)
             at org.apache.commons.digester.Digester.addFactoryCreate(Digester.java:1936)
             at org.apache.commons.digester.xmlrules.DigesterRuleParser.addRuleInstances(DigesterRuleParser.java:240)
             at org.apache.commons.digester.Digester.addRuleSet(Digester.java:1663)
             at org.apache.commons.digester.xmlrules.FromXmlRuleSet.addRuleInstances(FromXmlRuleSet.java:145)
             at org.apache.commons.digester.Digester.addRuleSet(Digester.java:1663)
             at org.apache.commons.digester.xmlrules.DigesterLoader.createDigester(DigesterLoader.java:91)
             at digesterloadertest.DemoService.startService(DemoService.java:45)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
             at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
             at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
             at $Proxy0.start(Unknown Source)
             at org.jboss.system.ServiceController.start(ServiceController.java:416)
             at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
             at $Proxy4.start(Unknown Source)
             at org.jboss.deployment.SARDeployer.start(SARDeployer.java:261)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
             at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
             at $Proxy8.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:463)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            11:11:04,701 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
            MBeans waiting for other MBeans:
            ObjectName: digesterloadertest:service=DemoService
            state: FAILED
            I Depend On:
            Depends On Me: java.lang.NoClassDefFoundError: org/apache/commons/digester/ObjectCreationFactory
            
            MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM:
            ObjectName: digesterloadertest:service=DemoService
            state: FAILED
            I Depend On:
            Depends On Me: java.lang.NoClassDefFoundError: org/apache/commons/digester/ObjectCreationFactory
            
            


            • 3. Re: Yet another Class Loader problem - Please Help
              G.Rajasekhar Newbie

              i told to keep in TOMCAT_HOME and not JBOSS HOME jboss05

              Thanks

              • 4. Re: Yet another Class Loader problem - Please Help
                Manjula Jayaraman Newbie

                But i don't have TOMCAT_HOME as i'm using the the tomcat shipped within jboss container?

                • 5. Re: Yet another Class Loader problem - Please Help
                  G.Rajasekhar Newbie

                  I have to try it now and see it.

                  Thanks