glassfish
  1. glassfish
  2. GLASSFISH-11536

NoClassDefFoundError: Cannot deploy EAR with beans.xml and session bean contained in WAR

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: V3
    • Fix Version/s: 3.1_ms07
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: All

    • Issuezilla Id:
      11,536

      Description

      The attached enterprise application (NetBeans project) fails to deploy in glassfish.

      The war module works standalone but not within the ear.

      Here is the log:

      INFO:

      {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\Programme\sges-v3\glassfish\domains\domain1\autodeploy\bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\DOKUME~1\MAM020~1.000\LOKALE~1\Temp\fileinstall-1216822139805894261, felix.fileinstall.filter = null}

      INFO: Portable JNDI names for EJB TestBean1 :
      [java:global/EnterpriseApplication1/EnterpriseApplication1-ejb/TestBean1,
      java:global/EnterpriseApplication1/EnterpriseApplication1-ejb/TestBean1!module.ejb.TestBean1]
      INFO: Portable JNDI names for EJB TestBean2 :
      [java:global/EnterpriseApplication1/EnterpriseApplication1-war/TestBean2!module.war.TestBean2,
      java:global/EnterpriseApplication1/EnterpriseApplication1-war/TestBean2]
      INFO: Instantiated an instance of
      org.hibernate.validator.engine.resolver.JPATraversableResolver.
      INFO: nullID: /C:/Dokumente und Einstellungen/mam02072/Eigene
      Dateien/NetBeansProjects/security-scratch/EnterpriseApplication1/dist/gfdeploy/EnterpriseApplication1/EnterpriseApplication1-war_war/
      CLASSES: [class module.war.TestBean2, class
      org.netbeans.rest.application.config.ApplicationConfig]

      SCHWERWIEGEND: Exception while loading the app
      org.glassfish.deployment.common.DeploymentException: by
      java.lang.NoClassDefFoundError: module/war/TestBean2
      at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:169)
      at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:125)
      at
      org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:224)
      at
      com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:338)
      at
      com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
      at
      org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
      at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
      at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
      at
      com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
      at
      com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
      at
      com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      at
      com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      at
      com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      at
      com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      at
      com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      at
      com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      at
      com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      at
      com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      at
      com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError:
      module/war/TestBean2
      at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:344)
      at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:314)
      at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:273)
      at org.jboss.weld.util.Proxies.createProxyClass(Proxies.java:153)
      at org.jboss.weld.util.Proxies.createProxyClass(Proxies.java:141)
      at org.jboss.weld.bean.SessionBean.initProxyClass(SessionBean.java:210)
      at org.jboss.weld.bean.SessionBean.initialize(SessionBean.java:121)
      at
      org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(AbstractBeanDeployer.java:111)
      at
      org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:151)
      at
      org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:367)
      at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:167)
      ... 30 more
      Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError:
      module/war/TestBean2
      at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:169)
      at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:339)
      ... 40 more
      Caused by: java.lang.NoClassDefFoundError: module/war/TestBean2
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
      at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:181)
      at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:163)
      ... 41 more
      Caused by: java.lang.ClassNotFoundException: module.war.TestBean2
      at
      com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:713)
      at
      com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:626)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
      ... 48 more

        Issue Links

          Activity

          Hide
          Sanjeeb Sahoo added a comment -

          I can still see the issue with recent trunk builds. This bug does not belong to
          classloader module. It appears to me that incorrect classloader is used to
          bootstrap Weld which is more likely to be caused by incorrect classloader being
          set as the thread's context classloader by deployment backend. Assigning it to
          deployment team to investigate further.

          Show
          Sanjeeb Sahoo added a comment - I can still see the issue with recent trunk builds. This bug does not belong to classloader module. It appears to me that incorrect classloader is used to bootstrap Weld which is more likely to be caused by incorrect classloader being set as the thread's context classloader by deployment backend. Assigning it to deployment team to investigate further.
          Hide
          Hong Zhang added a comment -

          The thread context classloader of the APPLICATION_LOADED event (which sent from
          ApplicationInfo) is set to be the top level application classloader. In case of
          a standalone module, it's the same as the module classloader which knows how to
          load classes in the module, but in case of ear, the top level application
          classloader is different than the web module classloader which does not know
          how to load classes in the module.

          Seems like the CDI code needs to listen to Deployment.MODULE_LOADED event
          instead (sent from ModuleInfo class) so it gets the module classloader instead.

          I have modified the ModueInfo class so that when we send the module load event,
          the thread context has the proper classloader (module classloader).

          Show
          Hong Zhang added a comment - The thread context classloader of the APPLICATION_LOADED event (which sent from ApplicationInfo) is set to be the top level application classloader. In case of a standalone module, it's the same as the module classloader which knows how to load classes in the module, but in case of ear, the top level application classloader is different than the web module classloader which does not know how to load classes in the module. Seems like the CDI code needs to listen to Deployment.MODULE_LOADED event instead (sent from ModuleInfo class) so it gets the module classloader instead. I have modified the ModueInfo class so that when we send the module load event, the thread context has the proper classloader (module classloader).
          Hide
          Sivakumar Thyagarajan added a comment -

          This issue is the same as 14842. A fix for that is being worked on and a fix would be checked in a few days.

          Show
          Sivakumar Thyagarajan added a comment - This issue is the same as 14842. A fix for that is being worked on and a fix would be checked in a few days.
          Hide
          Sivakumar Thyagarajan added a comment -

          Marking this as a duplicate. I was able to ensure that the attached EAR in this application also works with the fix for 14842

          Show
          Sivakumar Thyagarajan added a comment - Marking this as a duplicate. I was able to ensure that the attached EAR in this application also works with the fix for 14842
          Hide
          alniks added a comment - - edited

          The problem remains in glassfish 3.1.1. I have reproduced it in a simple CDI maven EAR application attached, with the following exception:

          Caused by: java.lang.ClassNotFoundException: com.alniks.test.cdi.web.LoggingInterceptor
          at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:787)
          at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:696)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
          at org.jboss.weld.resources.DefaultResourceLoader.classForName(DefaultResourceLoader.java:52)
          at org.jboss.weld.manager.Enabled$ClassLoader.apply(Enabled.java:71)
          ... 41 more

          PS: The attached application has been deployed through Netbeans on Windows 7 x64. The application deploys and runs fine on JBoss 7.

          Show
          alniks added a comment - - edited The problem remains in glassfish 3.1.1. I have reproduced it in a simple CDI maven EAR application attached, with the following exception: Caused by: java.lang.ClassNotFoundException: com.alniks.test.cdi.web.LoggingInterceptor at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:787) at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:696) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at org.jboss.weld.resources.DefaultResourceLoader.classForName(DefaultResourceLoader.java:52) at org.jboss.weld.manager.Enabled$ClassLoader.apply(Enabled.java:71) ... 41 more PS: The attached application has been deployed through Netbeans on Windows 7 x64. The application deploys and runs fine on JBoss 7.

            People

            • Assignee:
              Sivakumar Thyagarajan
              Reporter:
              keil
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: