Skip to main content

CDI + EJB in WAR inside EAR > NoClassDefFoundError (with example)

No replies
whshub
Offline
Joined: 2010-02-27

I'm struggling with either a misunderstanding/misconfiguration or a bug.

I'm trying to enable CDI in a war that is within an ear. If I enable CDI via beans.xml, I can't use EJBs (@Stateless, etc) within the same war as Glassfish throws a NoClassDefFoundError on deployment. (The no class def found is for the stateless ejb.)

If I deploy the war directly (not within the ear) everything deploys fine.
If I either remove the ejb annotation or remove beans.xml, the ear deploys fine.

I've attached an example ear as well the backing source code. This is the simplest example of the problem. It includes an ear with only one module (the war). The war has only one class, a @Stateless. The war also includes beans.xml and web.xml.

I tried this in 3.0.1 as well 3.1b19/3.1b20. All fail to deploy the ear. I saw another war/cdi bug in bug tracking but this seems different.

Am I doing something wrong? Full body of key exception follows.

Thanks,
Jacques

PS: Adding a @Local interface on the @Stateless no impact on the problem.

Exception

[#|2010-09-20T18:45:11.516-0700|SEVERE|glassfish3.0.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=12;_ThreadName=Thread-1;|Exception while loading the app
org.glassfish.deployment.common.DeploymentException: by java.lang.NoClassDefFoundError: com/test/problems/noclass/ExampleStateless
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:167)
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: com/test/problems/noclass/ExampleStateless
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:187)
at org.jboss.weld.util.Proxies.createProxyClass(Proxies.java:168)
at org.jboss.weld.bean.SessionBean.initProxyClass(SessionBean.java:221)
at org.jboss.weld.bean.SessionBean.initialize(SessionBean.java:143)
at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(AbstractBeanDeployer.java:110)
at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:151)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:377)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:165)
... 30 more
Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: com/test/problems/noclass/ExampleStateless
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: com/test/problems/noclass/ExampleStateless
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at sun.reflect.GeneratedMethodAccessor43.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: com.test.problems.noclass.ExampleStateless
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:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 48 more
|#]