Yet another Class Loader problem - Please Help
jboss05 Sep 7, 2005 1:15 AMHi 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>