[
https://issues.jboss.org/browse/WELD-889?page=com.atlassian.jira.plugin.s...
]
henk de boer commented on WELD-889:
-----------------------------------
I was quickly able to generate a stack trace for a similar case when I inject an EJB from
an EJB module into a CDI enhanced JAX-RS resource in a WEB module, belonging to the same
EAR:
01:40:29,349 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/restful].[default]]
Servlet.service() for servlet default threw exception:
org.jboss.resteasy.spi.UnhandledException: org.jboss.weld.exceptions.CreationException:
WELD-000079 Could not find the EJB in JNDI: class
com.foo.test.persistence.impl.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$users$henk$eclipse36$servers$jboss-6$0$0$Final$server$default$deploy$test_api$ear"-SessionBean-TestDAO_$$_WeldProxy
at
org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:329)
[:6.0.0.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:305)
[:6.0.0.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:198)
[:6.0.0.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:174)
[:6.0.0.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:518)
[:6.0.0.Final]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:480)
[:6.0.0.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:139)
[:6.0.0.Final]
at
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:211)
[:6.0.0.Final]
at
org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59)
[:6.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
[:6.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
[:6.0.0.Final]
at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
[:6.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
[:6.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
[:6.0.0.Final]
at com.foo.test.api.filters.RequestLoggingFilter.doFilter(RequestLoggingFilter.java:47)
[:]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
[:6.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
[:6.0.0.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[:6.0.0.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
[:6.0.0.Final]
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
[:6.0.0.Final]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:593)
[:6.0.0.Final]
at
org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)
[:1.1.0.Final]
at
org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)
[:1.1.0.Final]
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
[:6.0.0.Final]
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
[:6.0.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
[:6.0.0.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[:6.0.0.Final]
at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
[:6.0.0.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[:6.0.0.Final]
at
org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
[:6.0.0.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
[:6.0.0.Final]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[:6.0.0.Final]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)
[:6.0.0.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
[:6.0.0.Final]
at java.lang.Thread.run(Thread.java:637) [:1.6.0_20]
Caused by: org.jboss.weld.exceptions.CreationException: WELD-000079 Could not find the EJB
in JNDI: class
com.foo.test.persistence.impl.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$users$henk$eclipse36$servers$jboss-6$0$0$Final$server$default$deploy$test_api$ear"-SessionBean-TestDAO_$$_WeldProxy
at org.jboss.weld.bean.SessionBean.create(SessionBean.java:348) [:6.0.0.Final]
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:67)
[:6.0.0.Final]
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:669)
[:6.0.0.Final]
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:751)
[:6.0.0.Final]
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:138)
[:6.0.0.Final]
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:872) [:6.0.0.Final]
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:884) [:6.0.0.Final]
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:182)
[:6.0.0.Final]
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:54)
[:6.0.0.Final]
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:176)
[:6.0.0.Final]
at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:142)
[:6.0.0.Final]
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:170)
[:6.0.0.Final]
at org.jboss.resteasy.cdi.JaxrsInjectionTarget.inject(JaxrsInjectionTarget.java:36)
[:6.0.0.Final]
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:339) [:6.0.0.Final]
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:121) [:6.0.0.Final]
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)
[:6.0.0.Final]
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:87)
[:6.0.0.Final]
at
com.foo.test.api.resources.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$users$henk$eclipse36$servers$jboss-6$0$0$Final$server$default$deploy$test_api$ear$test_api_web$war$"-ManagedBean-class_com$bar$test$api$resources$JAXRSResource_$$_WeldClientProxy.getLeads(org$jboss$weld$bean-jboss$classloader:id="vfs:$$$users$henk$eclipse36$servers$jboss-6$0$0$Final$server$default$deploy$test_api$ear$test_api_web$war$"-ManagedBean-class_com$bar$test$api$resources$JAXRSResource_$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[:1.6.0_20]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[:1.6.0_20]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_20]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
[:6.0.0.Final]
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:252)
[:6.0.0.Final]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:217) [:6.0.0.Final]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:206) [:6.0.0.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:503)
[:6.0.0.Final]
... 30 more
Caused by: java.lang.NullPointerException
at
org.jboss.ejb3.endpoint.deployers.DefaultEJBIdentifier.identifyEJB(DefaultEJBIdentifier.java:63)
[:0.1.4]
at
org.jboss.ejb3.endpoint.deployers.DefaultEndpointResolver.resolve(DefaultEndpointResolver.java:37)
[:0.1.4]
at
org.jboss.weld.integration.ejb.JBossSessionObjectReference.<init>(JBossSessionObjectReference.java:61)
[:6.0.0.Final]
at org.jboss.weld.integration.ejb.JBossEjbServices.resolveEjb(JBossEjbServices.java:65)
[:6.0.0.Final]
at org.jboss.weld.bean.SessionBean.createReference(SessionBean.java:476) [:6.0.0.Final]
at
org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.<init>(EnterpriseBeanProxyMethodHandler.java:75)
[:6.0.0.Final]
at org.jboss.weld.bean.SessionBean.create(SessionBean.java:331) [:6.0.0.Final]
... 56 more
The code works as soon as I move the EJB from the EJB module to the WEB module. If you
haven't already, please also take a look at the forum link I provided which talks
about the exact same issue at:
http://seamframework.org/Community/ProblemsWithStatelessBeansInWeldCR101CR2
@Inject fails for EJBs not defined in web module
------------------------------------------------
Key: WELD-889
URL:
https://issues.jboss.org/browse/WELD-889
Project: Weld
Issue Type: Bug
Components: Resolution (Typesafe and by Name)
Affects Versions: 1.1.0.Beta2
Environment: JBoss AS 6 Final
Reporter: henk de boer
Trying to inject an EJB bean using @Inject into a bean in a web module fails when the EJB
in question is defined in an EJB module. Injecting an EJB that is defined in the web
module works as expected.
The exception raised is:
org.jboss.weld.exceptions.CreationException: WELD-000079 Could not find the EJB in JNDI
Example:
@RequestScoped
public class MyBeanA {
@Inject
private UserDAOA userDAO; // EJB defined in EJB module, fails
public void test() {
userDao.getByID(...);
}
}
@RequestScoped
public class MyBeanB {
@Inject
private UserDAO userDAOB; // EJB defined in (same) web module, works
public void test() {
userDao.getByID(...);
}
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira