users@glassfish.java.net

Using CDI in EAR results in classpath problems.

From: <glassfish_at_javadesktop.org>
Date: Fri, 26 Feb 2010 13:08:28 PST

Hi,

following the example of Adam Bien in http://www.adam-bien.com/roller/abien/entry/ejb_3_1_killed_the with a single WAR project deployed to Glassfish works fine. However, when this WAR file is included in an EAR project (including other EJB jars) an exception is thrown when the project is initialized.

When the beans.xml is removed from the WAR the project gets deployed but obviously dependency injection is not working anymore.

The following callstack is given:
SEVERE: Exception while loading the app
org.glassfish.deployment.common.DeploymentException: by java.lang.NoClassDefFoundError: nl/sisirhc/calculator/ejb/ClientProcessor
        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:637)
Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: nl/sisirhc/calculator/ejb/ClientProcessor
        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: nl/sisirhc/calculator/ejb/ClientProcessor
        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: nl/sisirhc/calculator/ejb/ClientProcessor
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:698)
        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: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: nl.sisirhc.calculator.ejb.ClientProcessor
        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:315)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
        ... 49 more

nl.sisirhc.calculator.ejb.ClientProcessor is:
@Stateless
@Named("clientProcessor")
public class ClientProcessor {

    public String getHello() {
        return "Hello World";
    }
}


Chris
[Message sent by forum member 'sisirhc' (chriswesdorp_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=389008