Rich DiCroce created WFLY-10293:
-----------------------------------
Summary: IllegalStateException when instantiating CDI bean that is injected
into a MDB
Key: WFLY-10293
URL:
https://issues.jboss.org/browse/WFLY-10293
Project: WildFly
Issue Type: Bug
Components: EJB
Affects Versions: 12.0.0.Final
Reporter: Rich DiCroce
I have a MDB that injects an ApplicationScoped CDI bean and calls a method on it. The CDI
bean injects UserTransaction, which is used in a second method that is never invoked by
the MDB.
If it happens that the MDB is the first thing to call the CDI bean, Weld tries to
instantiate the bean and fails with WFLYEJB0137. IMO this should succeed since it works as
long as something else is the first thing to use the CDI bean.
{code}
2018-04-24 08:17:38,429 ERROR
[com.sgi.song.gp.service.SONGv1.event.EventQueueHelper$Proxy$_$$_WeldSubclass] (Thread-9
(ActiveMQ-client-global-threads)) Error processing event publish. Event data is
EventQueueData [event=EventPublish{id=1524572231949-1446, type=Client-Connected,
data=null, level=1, timestamp=2018-04-24T12:17:38.415Z, properties={group=CCA,
name=ACE2D30CC916, class=CA, macAddress=ACE2D30CC916, site=46673101, jurisdiction=MD,
remoteIP=10.230.56.210, remotePort=51032, known=true, rejected=false,
NMS_showInCMC=false}}, requestId=null, source=GP.GP_QTS_2.GP.0050569A2F9E.QTS.MD,
rsvp=false]: java.lang.IllegalArgumentException: WFLYWELD0049: Error injecting resource
into CDI managed bean. Can't find a resource named java:comp/UserTransaction defined
on private javax.transaction.UserTransaction
com.sgi.song.gp.service.SONGv1.event.SONGEventDAO.tx
at
org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices.resolveResource(WeldResourceInjectionServices.java:239)
at
org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices$1.createResource(WeldResourceInjectionServices.java:183)
at
org.jboss.weld.injection.AbstractResourceInjection.getResourceReference(AbstractResourceInjection.java:49)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.injection.AbstractResourceInjection.injectResourceReference(AbstractResourceInjection.java:63)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.util.Beans.injectEEFields(Beans.java:308)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:68)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:102)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
com.sgi.song.gp.service.SONGv1.event.SONGEventDAO$Proxy$_$$_WeldClientProxy.findEvent(Unknown
Source) [classes:]
at
com.sgi.song.gp.service.SONGv1.event.EventQueueHelper.processEvent(EventQueueHelper.java:172)
[classes:]
at
com.sgi.song.gp.service.SONGv1.event.EventQueueHelper.processEvent(EventQueueHelper.java:128)
[classes:]
at
com.sgi.song.gp.service.SONGv1.event.EventQueueHelper$Proxy$_$$_WeldSubclass.processEvent$$super(Unknown
Source) [classes:]
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source) [:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_144]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.8.0_144]
at
org.jboss.weld.interceptor.proxy.TerminalAroundInvokeInvocationContext.proceedInternal(TerminalAroundInvokeInvocationContext.java:51)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:78)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.invokeInCallerTx(TransactionalInterceptorBase.java:132)
[narayana-jts-idlj-5.5.31.Final.jar:5.5.31.Final (revision: 78792)]
at
com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorMandatory.doIntercept(TransactionalInterceptorMandatory.java:59)
[narayana-jts-idlj-5.5.31.Final.jar:5.5.31.Final (revision: 78792)]
at
com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:79)
[narayana-jts-idlj-5.5.31.Final.jar:5.5.31.Final (revision: 78792)]
at
com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorMandatory.intercept(TransactionalInterceptorMandatory.java:51)
[narayana-jts-idlj-5.5.31.Final.jar:5.5.31.Final (revision: 78792)]
at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source) [:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_144]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.8.0_144]
at
org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
com.sgi.song.gp.service.SONGv1.event.EventQueueHelper$Proxy$_$$_WeldSubclass.processEvent(Unknown
Source) [classes:]
at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source) [:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_144]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.8.0_144]
at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)
[weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
at
com.sgi.song.gp.service.SONGv1.event.EventQueueHelper$Proxy$_$$_WeldClientProxy.processEvent(Unknown
Source) [classes:]
at
com.sgi.song.gp.service.SONGv1.event.EventQueueProcessor.onMessage(EventQueueProcessor.java:35)
[classes:]
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source) [:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_144]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.8.0_144]
at
org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
at
org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:90)
at
org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:101)
at
org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
[wildfly-ee-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:40)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
at
org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:332)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:238)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
at
org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:81)
[weld-ejb-3.0.3.Final.jar:3.0.3.Final]
at
org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.deployment.processors.EjbSuspendInterceptor.processInvocation(EjbSuspendInterceptor.java:57)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription$5$1.processInvocation(MessageDrivenComponentDescription.java:243)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at
org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:438)
at
org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:619)
[wildfly-elytron-1.2.2.Final.jar:1.2.2.Final]
at
org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:57)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198)
at
org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)
at
org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:81)
at com.sgi.song.gp.service.SONGv1.event.EventQueueProcessor$$$view2.onMessage(Unknown
Source) [classes:]
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source) [:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.8.0_144]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.8.0_144]
at
org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:139)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at
org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at com.sgi.song.gp.service.SONGv1.event.EventQueueProcessor$$$endpoint1.onMessage(Unknown
Source) [classes:]
at
org.apache.activemq.artemis.ra.inflow.ActiveMQMessageHandler.onMessage(ActiveMQMessageHandler.java:303)
at
org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1001)
at
org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:49)
at
org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1124)
at
org.apache.activemq.artemis.utils.OrderedExecutorFactory$OrderedExecutor$ExecutorTask.run(OrderedExecutorFactory.java:122)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_144]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_144]
Caused by: javax.naming.NameNotFoundException: UserTransaction [Root exception is
java.lang.IllegalStateException: WFLYEJB0137: Only session and message-driven beans with
bean-managed transaction demarcation are allowed to access UserTransaction]
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:153)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
at
org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:239)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
at javax.naming.InitialContext.lookup(Unknown Source) [rt.jar:1.8.0_144]
at javax.naming.InitialContext.lookup(Unknown Source) [rt.jar:1.8.0_144]
at
org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices.resolveResource(WeldResourceInjectionServices.java:237)
... 119 more
Caused by: java.lang.IllegalStateException: WFLYEJB0137: Only session and message-driven
beans with bean-managed transaction demarcation are allowed to access UserTransaction
at
org.jboss.as.ejb3.component.allowedmethods.AllowedMethodsInformation.realCheckPermission(AllowedMethodsInformation.java:138)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at
org.jboss.as.ejb3.component.allowedmethods.AllowedMethodsInformation.checkAllowed(AllowedMethodsInformation.java:112)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at
org.jboss.as.ejb3.subsystem.EJB3UserTransactionAccessControlService$1.authorizeAccess(EJB3UserTransactionAccessControlService.java:53)
[wildfly-ejb3-12.0.0.Final.jar:12.0.0.Final]
at
org.jboss.as.txn.service.UserTransactionAccessControlService.authorizeAccess(UserTransactionAccessControlService.java:83)
at
org.jboss.as.txn.service.UserTransactionBindingService$1.getReference(UserTransactionBindingService.java:71)
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:143)
[wildfly-naming-12.0.0.Final.jar:12.0.0.Final]
... 128 more
{code}
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)