7 Replies Latest reply on Aug 10, 2006 5:32 PM by ssilvert

    Class loading problem

    rdewell

      An ejb3 file with Seam components contains references to classes in another jar file (paypal_stubs.jar). When Seam "analyzes" the Component that references the paypal libraries, however, an NoClassDefFoundError is thrown:

      ----
      ket-hosted]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      java.lang.NoClassDefFoundError: com/paypal/soap/api/AbstractResponseType
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
      at java.lang.Class.getDeclaredMethods(Class.java:1763)
      at org.jboss.seam.Component.initMembers(Unknown Source)
      at org.jboss.seam.Component.(Unknown Source)
      at org.jboss.seam.Component.(Unknown Source)
      ----

      Both paypal_stubs.jar and jboss-seam.jar are inside the ejb file, at the top level. Any ideas why this is happening? Has jboss not "loaded" paypal_stubs.jar before jboss-seam.jar does its component scan? Any workarounds known? I thought all of the third party jars should go right at the top of the .ejb file, right where seam, facelets, etc jars are.

      I also tried putting the jars at the root of the .ear file, and then using Manifest to reference them, but that didn't work either.

      Been at this problem for quite a while, and any suggestions are welcome.

      Ryan

        • 1. Re: Class loading problem
          rdewell

          I guess this isn't a Seam issue, despite the error. When I do some other jar shuffling, I get a similar no class found error, but coming from jboss trying to start the bean. Weird. So this isn't the forum for this problem. But if anyone happens upon this message and has any ideas, I'm all ears. :)

          Ryan

          • 2. Re: Class loading problem
            gavin.king

            i'm not an expert on jboss as classloading, better to ask this in the ejb3 forum

            • 3. Re: Class loading problem

              Hi. I'm getting a similar error. In my case an interface of mine cannot be found. The error seems random such that if I just redeploy, the error goes away. This used to work... I'm using Seam from CVS.

              Is Seam errantly tring to load interfaces and abstract classes as classes?

              My stack trace is below. Does anybody have an idea of what is happening?

              18:54:41,018 ERROR [[/noticeboard]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
              net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
               at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
               at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
               at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
               at org.jboss.seam.Component.createProxyFactory(Component.java:1585)
               at org.jboss.seam.Component.<init>(Component.java:218)
               at org.jboss.seam.Component.<init>(Component.java:165)
               at org.jboss.seam.init.Initialization.addComponent(Initialization.java:933)
               at org.jboss.seam.init.Initialization.addComponent(Initialization.java:955)
               at org.jboss.seam.init.Initialization.addComponents(Initialization.java:863)
               at org.jboss.seam.init.Initialization.init(Initialization.java:550)
               at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:32)
               at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
               at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
               at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
               at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
               at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
               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:585)
               at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
               at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.apache.catalina.core.StandardContext.init(StandardContext.java:5116)
               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:585)
               at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
               at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297)
               at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103)
               at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371)
               at org.jboss.web.WebModule.startModule(WebModule.java:83)
               at org.jboss.web.WebModule.startService(WebModule.java:61)
               at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
               at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
               at sun.reflect.GeneratedMethodAccessor1248.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:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
               at $Proxy0.start(Unknown Source)
               at org.jboss.system.ServiceController.start(ServiceController.java:417)
               at sun.reflect.GeneratedMethodAccessor5.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:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
               at $Proxy43.start(Unknown Source)
               at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
               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:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
               at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
               at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
               at org.jboss.ws.server.WebServiceDeployer.start(WebServiceDeployer.java:117)
               at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
               at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
               at $Proxy44.start(Unknown Source)
               at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
               at org.jboss.deployment.MainDeployer.start(MainDeployer.java:997)
               at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
               at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
               at sun.reflect.GeneratedMethodAccessor12.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:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               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:585)
               at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:266)
               at sun.reflect.GeneratedMethodAccessor55.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:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:179)
               at sun.reflect.GeneratedMethodAccessor54.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:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:819)
               at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:420)
               at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
               at sun.rmi.transport.Transport$1.run(Transport.java:153)
               at java.security.AccessController.doPrivileged(Native Method)
               at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
               at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
               at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
               at java.lang.Thread.run(Thread.java:613)
              Caused by: java.lang.reflect.InvocationTargetException
               at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
               at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
               ... 130 more
              Caused by: java.lang.NoClassDefFoundError: com/jellymold/audit/Auditable
               at java.lang.ClassLoader.defineClass1(Native Method)
               at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
               ... 135 more


              • 4. Re: Class loading problem
                ssilvert

                 

                "rdewell" wrote:


                Both paypal_stubs.jar and jboss-seam.jar are inside the ejb file, at the top level. Any ideas why this is happening? Has jboss not "loaded" paypal_stubs.jar before jboss-seam.jar does its component scan? Any workarounds known? I thought all of the third party jars should go right at the top of the .ejb file, right where seam, facelets, etc jars are.

                Been at this problem for quite a while, and any suggestions are welcome.

                Ryan


                Here's a trick you can try. Go to deploy\jbossweb-tomcat55.sar\META-INF\jboss-service.xml
                set true

                Often, the problem is that something packaged at the EJB or EAR level references something packaged in the WAR. With the Tomcat classloader, this won't work. (WAR classes can reference EJB classes, but the converse is not true). When using the JBoss classloader for WARs, any class can generally reference any other class.

                Exceptions to the above have to do with repository configuration. See http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

                For a general checklist that helps to debug NoClassDefFoundError, see http://wiki.jboss.org/wiki/Wiki.jsp?page=GetClassNotFoundExceptionOrNoClassDefFoundError

                Stan

                • 5. Re: Class loading problem
                  ssilvert

                   

                  "stan.silvert@jboss.com" wrote:


                  Here's a trick you can try. Go to deploy\jbossweb-tomcat55.sar\META-INF\jboss-service.xml
                  set <attribute name="UseJBossWebLoader">true</attribute>


                  Uh, I meant set UseJBossWebLoader = true

                  • 6. Re: Class loading problem

                    Stan, thanks for the help. Your UseJBossWebLoader trick did not work for me though.

                    Is this perhaps a problem with org.jboss.seam.Component.createProxyFactory? This seems to be calling net.sf.cglib.proxy.Enhancer.createClass on my interface and on rdewell's abstract class.

                    What does Gavin think?

                    • 7. Re: Class loading problem
                      ssilvert

                      Did you try the checklist? That list pretty much covers every NoClassDefFound problem you can have.

                      The nastiest is the one about compiling with an older version. For instance if you compile with JDK 1.5 and run with JDK 1.4, you sometimes get NoClassDefFoundError instead of a class version error. What makes this harder to track down is that the problem might be that a superclass was compiled with JDK 1.5. The error will be reported on the subclass.

                      Stan