3 Replies Latest reply on Feb 15, 2004 12:39 PM by Scott Stark

    Help! Inner class not found - why?

    David Brady Newbie

      This is DRIVING me nuts. Any help or hints would be appreciated.

      Using Jboss 3.2.3 and have am deploying a .war. It includes many classes, among which:


      jar -tf mzlet.war | grep -e MContainer
      WEB-INF/classes/com/m/container/servlet/MContainerServlet$1.class
      WEB-INF/classes/com/m/container/servlet/MContainerServlet.class


      When I start up Jboss I get the following error - full output below:


      10:46:51,385 ERROR [Engine] StandardContext[/mzlet]: Servlet /mzlet threw load() exception
      javax.servlet.ServletException: Servlet.init() for servlet mz threw exception
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:963)
      ...
      10:46:51,385 ERROR [Engine] ----- Root Cause -----
      java.lang.NoClassDefFoundError: com/m/container/servlet/MContainerServlet$1
      at com.m.container.servlet.MContainerServlet.initialize(MContainerServlet.java:163)
      at com.m.container.servlet.MContainerServlet.initializeIfNeeded(MContainerServlet.java:107)
      at com.m.container.servlet.MContainerServlet.init(MContainerServlet.java:114)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)


      The inner class, MContainerServlet$1, can't be found despite it sitting alongside MContainerServlet in the .war.

      I added a debugging statement to output some classloading information just before MContainerServlet tries to use the inner class. The classloader is clearly finding MContainerServlet:


      10:46:51,385 INFO [STDOUT] Classloader information: '/com/m/container/servlet/MContainerServlet.class' found
      in '/jboss-3.2.3/server/M/tmp/deploy/...
      ...tmp39779mzlet.war/WEB-INF/classes/com/m/container/servlet/MContainerServlet.class' via class loader 'org.jboss.mx.loading.UnifiedClassLoader3'


      Why can't it find the inner class?


      FULL OUTPUT:


      10:46:51,385 INFO [STDOUT] Classloader information: '/com/m/container/servlet/MContainerServlet.class' found
      in '/jboss-3.2.3/server/M/tmp/deploy/...
      ...tmp39779mzlet.war/WEB-INF/classes/com/m/container/servlet/MContainerServlet.class' via class loader 'org.jboss.mx.loading.UnifiedClassLoader3'
      10:46:51,385 ERROR [Engine] StandardContext[/mzlet]: Servlet /mzlet threw load() exception
      javax.servlet.ServletException: Servlet.init() for servlet mz threw exception
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:963)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3422)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3623)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.createWebContext(EmbeddedTomcatService.java:549)
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.performDeploy(EmbeddedTomcatService.java:309)
      at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:428)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
      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.start(ServiceMBeanSupport.java:192)
      at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
      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.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy5.deploy(Unknown Source)
      at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
      at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
      at org.jboss.Main.boot(Main.java:150)
      at org.jboss.Main$1.run(Main.java:395)
      at java.lang.Thread.run(Thread.java:536)
      10:46:51,385 ERROR [Engine] ----- Root Cause -----
      java.lang.NoClassDefFoundError: com/m/container/servlet/MContainerServlet$1
      at com.m.container.servlet.MContainerServlet.initialize(MContainerServlet.java:163)
      at com.m.container.servlet.MContainerServlet.initializeIfNeeded(MContainerServlet.java:107)
      at com.m.container.servlet.MContainerServlet.init(MContainerServlet.java:114)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3422)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3623)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.createWebContext(EmbeddedTomcatService.java:549)
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.performDeploy(EmbeddedTomcatService.java:309)
      at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:428)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
      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.start(ServiceMBeanSupport.java:192)
      at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
      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.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy5.deploy(Unknown Source)
      at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
      at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
      at org.jboss.Main.boot(Main.java:150)
      at org.jboss.Main$1.run(Main.java:395)
      at java.lang.Thread.run(Thread.java:536)

        • 1. Re: Help! Inner class not found - why?
          David Brady Newbie

          OK - can this message be made a bit more - um - specific?

          10:46:51,385 ERROR [Engine] ----- Root Cause -----
          java.lang.NoClassDefFoundError: com/m/container/servlet/MContainerServlet$1

          It wasn't that the MContainerServlet$1 couldn't be found - it was a 3rd party library class that this one depends on!

          Actually, I'm completely serious. This misleading message caused me to waste more time that I'd care to admit. Is there a way for the Jboss class loader to report what the real issue is?

          "luxmatic" wrote:
          This is DRIVING me nuts. Any help or hints would be appreciated.

          Using Jboss 3.2.3 and have am deploying a .war. It includes many classes, among which:


          jar -tf mzlet.war | grep -e MContainer
          WEB-INF/classes/com/m/container/servlet/MContainerServlet$1.class
          WEB-INF/classes/com/m/container/servlet/MContainerServlet.class


          When I start up Jboss I get the following error - full output below:


          10:46:51,385 ERROR [Engine] StandardContext[/mzlet]: Servlet /mzlet threw load() exception
          javax.servlet.ServletException: Servlet.init() for servlet mz threw exception
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:963)
          ...
          10:46:51,385 ERROR [Engine] ----- Root Cause -----
          java.lang.NoClassDefFoundError: com/m/container/servlet/MContainerServlet$1
          at com.m.container.servlet.MContainerServlet.initialize(MContainerServlet.java:163)
          at com.m.container.servlet.MContainerServlet.initializeIfNeeded(MContainerServlet.java:107)
          at com.m.container.servlet.MContainerServlet.init(MContainerServlet.java:114)
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)



          • 3. Re: Help! Inner class not found - why?
            Scott Stark Master

            File a bug report at: http://sourceforge.net/tracker/?group_id=22866&atid=376685

            with the details of how the third party class is used as a similar testcase invoking a servlet inner class referencing a missing class produces the expected error:

            10:15:20,930 ERROR [Engine] StandardContext[/test]StandardWrapper.Throwable
            java.lang.NoClassDefFoundError: No ClassLoaders found for: org.jboss.test.web.util.ClassInClasses
            at org.jboss.test.web.servlets.ClasspathServlet2.class$(ClasspathServlet2.java:21)
            at org.jboss.test.web.servlets.ClasspathServlet2$UtilUser.(ClasspathServlet2.java:28)
            at org.jboss.test.web.servlets.ClasspathServlet2.init(ClasspathServlet2.java:33)
            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
            at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887)
            at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3960)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4283)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:850)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:638)

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)