java.lang.IllegalStateException: Only session beans with bean-managed transactions can obtain UserTransaction

Stack Overflow | Tirath | 2 months ago
  1. 0

    Save @Entity using @EntityManager not working

    Stack Overflow | 2 months ago | Tirath
    java.lang.IllegalStateException: Only session beans with bean-managed transactions can obtain UserTransaction
  2. 0

    WFLYEJB0137: Only session and message-driven beans with bean-managed transaction demarcation are allowed to access UserTransaction

    Stack Overflow | 1 year ago | El Lord Code
    org.springframework.transaction.TransactionSystemException: JTA UserTransaction is not available at JNDI location [java:jboss/UserTransaction]; nested exception is 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]
  3. 0

    How to programmable transaction in a entity bean?

    Oracle Community | 1 decade ago | 843830
    java.lang.IllegalStateException: Only instances of beans with bean-managed transaction demarcation can use getUserTransaction().
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to programmable transaction in a entity bean?

    Oracle Community | 1 decade ago | 843830
    java.lang.IllegalStateException: Only instances of beans with bean-managed transaction demarcation can use getUserTransaction().
  6. 0

    Calling TransactionAspectSupport.currentTransactionStatus( ).setRollbackOnly() result in an EJBException on transaction end. The client receives this Exception instead of receiving the normal return object. It seems like Spring is using UserTransaction to set rollback, but this is prohibited in CMT by EJB 2.1 specification. Using pure CMT with ejbContext.setRollbackOnly is working correctly. My bean configuration looks like this <bean id="BestandsBerechnerSTarget" class="de.solutionary.bps.session.bestandsfuehrung .BestandsBerechnerSImpl"></bean> <bean id="BestandsBerechnerSIntern" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean"> <property name="transactionManager" ref="jtaTM" /> <property name="target" ref="BestandsBerechnerSTarget" /> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED,timeout_500</prop> </props> </property> </bean> <bean id="BestandsBerechnerS" class="org.springframework.ejb.access.LocalStatele ssSessionProxyFactoryBean"> <property name="jndiName"> <value>java:comp/env/ejb/BestandsBerechnerSLocal</value> </property> <property name="businessInterface"> <value>de.solutionary.bps.session.bestandsfuehrung .BestandsBerechnerSBI</value> </property> </bean> Here is the stacktrace: 2006-09-04 10:50:06,894 ERROR (VorgangDetail.java:789) # Exception: javax.ejb.EJBException: An exception occurred during transaction completion: ; nested exception is: javax.transaction.RollbackException javax.transaction.RollbackException at com.evermind.server.ApplicationServerTransaction.c heckForRollbackOnlyWhileInCommit(ApplicationServer Transaction.java:537) at com.evermind.server.ApplicationServerTransaction.d oCommit(ApplicationServerTransaction.java:240) at com.evermind.server.ApplicationServerTransaction.c ommit(ApplicationServerTransaction.java:126) at com.evermind.server.ApplicationServerTransactionMa nager.commit(ApplicationServerTransactionManager.j ava:433) at com.evermind.server.ApplicationServer$2.commit(App licationServer.java:4540) at com.evermind.server.ejb.EJBTransactionManager.end( EJBTransactionManager.java:136) at com.evermind.server.ejb.interceptor.system.TxRequi redInterceptor.invoke(TxRequiredInterceptor.java:6 3) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInte rceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.StatelessSessionEJBObject. OC4J_invokeMethod(StatelessSessionEJBObject.java:8 6) at VorgangsEditorSLocal_StatelessSessionBeanWrapper0. addAbrechnungsVorgang(VorgangsEditorSLocal_Statele ssSessionBeanWrapper0.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.ejb.access.LocalSlsbInvokerInt erceptor.invoke(LocalSlsbInvokerInterceptor.java:7 1) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :170) at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:176) at $Proxy36.addAbrechnungsVorgang(Unknown Source) at de.mummert.abrechnung.web.abrechnung.VorgangDetail .speichern(VorgangDetail.java:741) at de.mummert.abrechnung.web.abrechnung.VorgangDetail .reactOnSpeichern(VorgangDetail.java:477) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.gasx.casabac.control.GXDialogElement.invokeAct ionMethod(GXDialogElement.java:188) at com.gasx.casabac.control.GXButton.onButton(GXButto n.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.softwareag.cis.server.InteractionModel.invokeM ethodInternally(Unknown Source) at com.softwareag.cis.server.InteractionModel.invokeM ethod(Unknown Source) at com.softwareag.cis.server.XMLProcessor.processXML( Unknown Source) at com.softwareag.cis.server.Connector.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet .java:763) at javax.servlet.http.HttpServlet.service(HttpServlet .java:856) at com.evermind.server.http.ServletRequestDispatcher. invoke(ServletRequestDispatcher.java:719) at com.evermind.server.http.ServletRequestDispatcher. forwardInternal(ServletRequestDispatcher.java:376) at com.evermind.server.http.HttpRequestHandler.doProc essRequest(HttpRequestHandler.java:870) at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:451) at com.evermind.server.http.HttpRequestHandler.serveO neRequest(HttpRequestHandler.java:218) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:119) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:112) at oracle.oc4j.network.ServerSocketReadHandler$SafeRu nnable.run(ServerSocketReadHandler.java:260) at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:303) at java.lang.Thread.run(Thread.java:595) javax.ejb.EJBException: An exception occurred during transaction completion: ; nested exception is: javax.transaction.RollbackException at com.evermind.server.ejb.EJBUtils.createEJBExceptio n(EJBUtils.java:352) at com.evermind.server.ejb.EJBTransactionManager.end( EJBTransactionManager.java:143) at com.evermind.server.ejb.interceptor.system.TxRequi redInterceptor.invoke(TxRequiredInterceptor.java:6 3) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInte rceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.StatelessSessionEJBObject. OC4J_invokeMethod(StatelessSessionEJBObject.java:8 6) at VorgangsEditorSLocal_StatelessSessionBeanWrapper0. addAbrechnungsVorgang(VorgangsEditorSLocal_Statele ssSessionBeanWrapper0.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.ejb.access.LocalSlsbInvokerInt erceptor.invoke(LocalSlsbInvokerInterceptor.java:7 1) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :170) at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:176) at $Proxy36.addAbrechnungsVorgang(Unknown Source) at de.mummert.abrechnung.web.abrechnung.VorgangDetail .speichern(VorgangDetail.java:741) at de.mummert.abrechnung.web.abrechnung.VorgangDetail .reactOnSpeichern(VorgangDetail.java:477) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.gasx.casabac.control.GXDialogElement.invokeAct ionMethod(GXDialogElement.java:188) at com.gasx.casabac.control.GXButton.onButton(GXButto n.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.softwareag.cis.server.InteractionModel.invokeM ethodInternally(Unknown Source) at com.softwareag.cis.server.InteractionModel.invokeM ethod(Unknown Source) at com.softwareag.cis.server.XMLProcessor.processXML( Unknown Source) at com.softwareag.cis.server.Connector.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet .java:763) at javax.servlet.http.HttpServlet.service(HttpServlet .java:856) at com.evermind.server.http.ServletRequestDispatcher. invoke(ServletRequestDispatcher.java:719) at com.evermind.server.http.ServletRequestDispatcher. forwardInternal(ServletRequestDispatcher.java:376) at com.evermind.server.http.HttpRequestHandler.doProc essRequest(HttpRequestHandler.java:870) at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:451) at com.evermind.server.http.HttpRequestHandler.serveO neRequest(HttpRequestHandler.java:218) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:119) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:112) at oracle.oc4j.network.ServerSocketReadHandler$SafeRu nnable.run(ServerSocketReadHandler.java:260) at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:303) at java.lang.Thread.run(Thread.java:595) Caused by: javax.transaction.RollbackException at com.evermind.server.ApplicationServerTransaction.c heckForRollbackOnlyWhileInCommit(ApplicationServer Transaction.java:537) at com.evermind.server.ApplicationServerTransaction.d oCommit(ApplicationServerTransaction.java:240) at com.evermind.server.ApplicationServerTransaction.c ommit(ApplicationServerTransaction.java:126) at com.evermind.server.ApplicationServerTransactionMa nager.commit(ApplicationServerTransactionManager.j ava:433) at com.evermind.server.ApplicationServer$2.commit(App licationServer.java:4540) at com.evermind.server.ejb.EJBTransactionManager.end( EJBTransactionManager.java:136) ... 42 more If I'm calling ejbContext.getUserTransaction().setRollbackOnly() in a pure CMT environment without Spring the following Exception is raised: 2006-09-05 10:52:24,031 FATAL (VorgangsEditorSImpl.java:2599) # java.lang.IllegalStateException: Only beans with user-managed transactions can invoke getUserTransaction() at com.evermind.server.ejb.AbstractEJBContext.getUser Transaction(AbstractEJBContext.java:262) at de.solutionary.bps.session.tankfarm.VorgangsEditor SImpl.addAbrechnungsVorgang(VorgangsEditorSImpl.ja va:2591) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:287) at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:181) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :148) at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:96) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :170) at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:176) at $Proxy36.addAbrechnungsVorgang(Unknown Source) at de.solutionary.bps.session.tankfarm.VorgangsEditor SBean.addAbrechnungsVorgang(VorgangsEditorSBean.ja va:654) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.evermind.server.ejb.interceptor.joinpoint.EJBJ oinPointImpl.invoke(EJBJoinPointImpl.java:35) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInte rceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.TxRequi redInterceptor.invoke(TxRequiredInterceptor.java:5 5) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInte rceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationCont extImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.StatelessSessionEJBObject. OC4J_invokeMethod(StatelessSessionEJBObject.java:8 6) at VorgangsEditorSLocal_StatelessSessionBeanWrapper0. addAbrechnungsVorgang(VorgangsEditorSLocal_Statele ssSessionBeanWrapper0.java:141) at de.mummert.abrechnung.web.abrechnung.VorgangDetail .speichern(VorgangDetail.java:747) at de.mummert.abrechnung.web.abrechnung.VorgangDetail .reactOnSpeichern(VorgangDetail.java:482) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.gasx.casabac.control.GXDialogElement.invokeAct ionMethod(GXDialogElement.java:188) at com.gasx.casabac.control.GXButton.onButton(GXButto n.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.softwareag.cis.server.InteractionModel.invokeM ethodInternally(Unknown Source) at com.softwareag.cis.server.InteractionModel.invokeM ethod(Unknown Source) at com.softwareag.cis.server.XMLProcessor.processXML( Unknown Source) at com.softwareag.cis.server.Connector.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet .java:763) at javax.servlet.http.HttpServlet.service(HttpServlet .java:856) at com.evermind.server.http.ServletRequestDispatcher. invoke(ServletRequestDispatcher.java:719) at com.evermind.server.http.ServletRequestDispatcher. forwardInternal(ServletRequestDispatcher.java:376) at com.evermind.server.http.HttpRequestHandler.doProc essRequest(HttpRequestHandler.java:870) at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:451) at com.evermind.server.http.HttpRequestHandler.serveO neRequest(HttpRequestHandler.java:218) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:119) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:112) at oracle.oc4j.network.ServerSocketReadHandler$SafeRu nnable.run(ServerSocketReadHandler.java:260) at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:303) at java.lang.Thread.run(Thread.java:595)

    Spring JIRA | 1 decade ago | Alexander Schulz
    java.lang.IllegalStateException: Only beans with user-managed transactions can invoke getUserTransaction() at com.evermind.server.ejb.AbstractEJBContext.getUser Transaction(AbstractEJBContext.java:262) at de.solutionary.bps.session.tankfarm.VorgangsEditor SImpl.addAbrechnungsVorgang(VorgangsEditorSImpl.ja va:2591) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Only session beans with bean-managed transactions can obtain UserTransaction

      at com.sun.ejb.containers.EJBContainerTransactionManager.getUserTransaction()
    2. Embedded GlassFish Web
      AbstractSessionContextImpl.getUserTransaction
      1. com.sun.ejb.containers.EJBContainerTransactionManager.getUserTransaction(EJBContainerTransactionManager.java:566)
      2. com.sun.ejb.containers.BaseContainer.getUserTransaction(BaseContainer.java:995)
      3. com.sun.ejb.containers.AbstractSessionContextImpl.getUserTransaction(AbstractSessionContextImpl.java:120)
      3 frames