tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John D. Ament" <john.d.am...@gmail.com>
Subject Re: Activemq embedded + createSession : unable to make it work!
Date Thu, 09 Oct 2014 13:07:04 GMT
Correct, you're using container managed transactions.  You cannot call
commit.

On Thu, Oct 9, 2014 at 8:58 AM, joeleclems <joeleclems@free.fr> wrote:

> i tried different kind of transaction within EJB.
>
> Here are results of my tests :
>
> 1. Inject a CMT EJB to receive message.
>
> My EJB :
> @Stateless
> @TransactionManagement(TransactionManagementType.CONTAINER)
> public class MyCMTEjbReceiver implements ICMTEjbReceiver, ExceptionListener
> {
> ...
>
> @Override
>         @TransactionAttribute(TransactionAttributeType.REQUIRED)
>         public void receiveMessage(int pType) {
> ...
> }
>
> When i call "session.commit()" in "receiveMessage" method, i have this
> exception :
>
> javax.jms.TransactionInProgressException: Cannot commit() if an XA
> transaction is already in progress
>         at
> org.apache.activemq.TransactionContext.commit(TransactionContext.java:304)
>         at
>
> org.apache.activemq.ra.ManagedTransactionContext.commit(ManagedTransactionContext.java:62)
>         at
> org.apache.activemq.ActiveMQSession.commit(ActiveMQSession.java:574)
>         at
>
> org.apache.activemq.ra.ManagedSessionProxy.commit(ManagedSessionProxy.java:108)
>         at
>
> org.apache.activemq.ActiveMQQueueSession.commit(ActiveMQQueueSession.java:72)
>         at
>
> test_jms.receiver.MyCMTEjbReceiver.validateMessage(MyCMTEjbReceiver.java:192)
>         at
>
> test_jms.receiver.MyCMTEjbReceiver.receiveMessage(MyCMTEjbReceiver.java:132)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
>         at
>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:308)
>         at com.sun.proxy.$Proxy123.receiveMessage(Unknown Source)
>         at
>
> test_jms.receiver.ServletControlReceiver.activateCMTEjbReceiver(ServletControlReceiver.java:69)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
>         at
> org.apache.openejb.util.proxy.ProxyEJB$Handler.invoke(ProxyEJB.java:74)
>         at
>
> test_jms.receiver.ServletControlReceiver$$LocalBeanProxy.activateCMTEjbReceiver(test_jms/receiver/ServletControlReceiver.java)
>         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
>
> org.apache.openejb.server.cxf.rs.OpenEJBEJBInvoker.performInvocation(OpenEJBEJBInvoker.java:89)
>         at
>
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
>         at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
>         at
>
> org.apache.openejb.server.cxf.rs.OpenEJBEJBInvoker.invoke(OpenEJBEJBInvoker.java:62)
>         at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:89)
>         at
>
> org.apache.openejb.server.cxf.rs.AutoJAXRSInvoker.invoke(AutoJAXRSInvoker.java:64)
>         at
>
> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:57)
>         at
>
> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:93)
>         at
>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>         at
>
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>         at
>
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:240)
>         at
>
> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttpListener.java:180)
>         at
> org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
>         at
>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
>         at
>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
>         at
>
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
>         at
>
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
>         at
> org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
>         at
>
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
>         at
>
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
>         at
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
>         at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
>         at
>
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
>         at
>
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
>         at
>
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
>         at
>
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
>         at
>
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.lang.Thread.run(Thread.java:662)
>
>
>
>
>
>
>
> 2. Inject a BMT EJB to receive message (to follow this link :
> http://activemq.apache.org/should-i-use-xa.html)
> My EJB :
> @Stateless
> @TransactionManagement(TransactionManagementType.BEAN)
> public class MyEjbReceiver implements IEjbReceiver, ExceptionListener {
>
> @Resource
>         private UserTransaction userTransaction;
> ...
>         public void receiveMessage(int pType) {
> userTransaction.begin();
> ...
> userTransaction.commit();
> session.commit();
> }
>
> ...
> }
>
>
> When i call "session.commit()" in "receiveMessage" method, i have this
> exception (again...) :
> javax.jms.IllegalStateException: Not a transacted session
>         at
> org.apache.activemq.ActiveMQSession.commit(ActiveMQSession.java:569)
>         at
>
> org.apache.activemq.ra.ManagedSessionProxy.commit(ManagedSessionProxy.java:108)
>         at
>
> org.apache.activemq.ActiveMQQueueSession.commit(ActiveMQQueueSession.java:72)
>         at
> test_jms.receiver.MyEjbReceiver.validateMessage(MyEjbReceiver.java:196)
>         at
> test_jms.receiver.MyEjbReceiver.receiveMessage(MyEjbReceiver.java:135)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
>         at
>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:308)
>         at com.sun.proxy.$Proxy120.receiveMessage(Unknown Source)
>         at
>
> test_jms.receiver.ServletControlReceiver.activateEjbReceiver(ServletControlReceiver.java:60)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
>         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
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
>         at
> org.apache.openejb.util.proxy.ProxyEJB$Handler.invoke(ProxyEJB.java:74)
>         at
>
> test_jms.receiver.ServletControlReceiver$$LocalBeanProxy.activateEjbReceiver(test_jms/receiver/ServletControlReceiver.java)
>         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
>
> org.apache.openejb.server.cxf.rs.OpenEJBEJBInvoker.performInvocation(OpenEJBEJBInvoker.java:89)
>         at
>
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
>         at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
>         at
>
> org.apache.openejb.server.cxf.rs.OpenEJBEJBInvoker.invoke(OpenEJBEJBInvoker.java:62)
>         at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:89)
>         at
>
> org.apache.openejb.server.cxf.rs.AutoJAXRSInvoker.invoke(AutoJAXRSInvoker.java:64)
>         at
>
> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:57)
>         at
>
> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:93)
>         at
>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
>         at
>
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>         at
>
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:240)
>         at
>
> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttpListener.java:180)
>         at
> org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
>         at
>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
>         at
>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
>         at
>
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
>         at
>
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
>         at
> org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
>         at
>
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
>         at
>
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
>         at
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
>         at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
>         at
>
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
>         at
>
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
>         at
>
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
>         at
>
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
>         at
>
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.lang.Thread.run(Thread.java:662)
>
> any clue?
>
> Here are updated source project :
> JmsTest3.zip
> <http://tomee-openejb.979440.n4.nabble.com/file/n4672193/JmsTest3.zip>
>
> Thanks
> Clément
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Activemq-embedded-createSession-unable-to-make-it-work-tp4672172p4672193.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message