Announcement Announcement Module
Collapse
No announcement yet.
setRollbackOnly with no EJBException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • setRollbackOnly with no EJBException

    Hi,

    I'm running spring 1.2.8 with Oracle OC4J 10.

    If I'm calling
    TransactionAspectSupport.currentTransactionStatus( ).setRollbackOnly();
    an EJBException is automaticaly raised after the method ends.

    How can I prevend this? In a "pure" EJB environment without spring I can return a normal result even if I setRollbackOnly. No Exception is automatically raised.

    How can I do this with Spring?

    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>

    Thanks in advance
    Alex

  • #2
    Can you post the stacktrace that you get? Normally you should not get an exception (quote from the TransactionStatus javadoc):
    * Set the transaction rollback-only. This instructs the transaction manager
    * that the only possible outcome of the transaction may be a rollback, as
    * alternative to throwing an exception which would in turn trigger a rollback.

    Comment


    • #3
      Stacktrace

      Tank you for the reply. 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

      Comment


      • #4
        Strange - from the logs it seems the check is executed (as the method implies) while the transaction does the commit and that one throws the exception.
        I've checked the ejb 2.1 spec again and the method result or application exception must be returned to the client - in this case the container returns its own exception.
        Have you tried the same behavior using the plain EJB scenario inside the same environment? Did you ask the OC4J forums?
        From the stacktrace it does seem to be a Spring issue ...

        Comment


        • #5
          I just changed the call back to pure EJB CMT. Now it is working correctly. No Exception is thrown.

          I searched Oracles Metalink for an issue like this but I found nothing. I'm using OC4J 10.1.3.0 in the "only EJB Container" edition.

          Thanks for your help.

          Comment


          • #6
            One difference might be that setting rollback on the UserTransaction behaves differently then calling setRollbackOnly on the EjbContext.
            Can you please post the code for the 'pure' EJB approach? - how are you rolling back the transaction?
            If you are using EjbContext try using using the UserTransaction instead. Thanks!

            Comment


            • #7
              Ok, I tried the UserTransaction.

              Here is the code fragment:

              ...
              if (!errCol.isEmpty()) {
              logger.error("Loese kein RollbackOnly aus:" + errCol.toString());
              if( ejbContext!=null ) {
              logger.error("EJB Rollback");
              ejbContext.getUserTransaction().setRollbackOnly();
              } else {
              TransactionAspectSupport.currentTransactionStatus( ).setRollbackOnly();
              }
              } else {
              geab.initData(vrg);
              }
              } catch (Exception e) {
              logger.fatal("", e);
              if( ejbContext!=null ) {
              logger.error("EJB Rollback");
              try {
              ejbContext.getUserTransaction().setRollbackOnly();
              } catch (Exception e1) {
              e1.printStackTrace();
              }
              } else {
              TransactionAspectSupport.currentTransactionStatus( ).setRollbackOnly();
              }
              errCol.addError(TextProperty.getText(this.getClass (), "ABRVRG_EXCEPTION"));
              }
              errRes = new ErrorCollectionResult(errCol);
              if (errCol.isEmpty()) {
              errRes.setMethodeReturnValue(geab);
              }
              return errRes;
              }

              It results in the following Exception:
              2006-09-05 10:52:14,627 ERROR (VorgangsEditorSImpl.java:2590) # EJB Rollback
              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)
              ...

              Looks like using UserTransaction with CMT is not allowed.

              Comment


              • #8
                So inside the scenario that works you are using EjbContext for setting the rollback only, right?
                if this is so, please raise an issue on JIRA - I'm not sure what the outcome might be since from the stacktrace it seems that Spring does signal the rollback appropriately to the server but OC4J choses to thrown an exception.

                Comment


                • #9
                  Originally posted by a_schulle
                  Looks like using UserTransaction with CMT is not allowed.
                  True. This is stated in the EJB specification (2.1) chapter 17.3.4.
                  It seems that this is enforced in your case. Only working with EJBContext#setRollbackOnly is allowed for CMP.

                  Regards,
                  Andreas

                  Comment


                  • #10
                    Thank you Costin, thank you Andreas for your help!

                    I will raise an issue on JIRA but I don't get it right now.

                    If UserTransaction is prohibited with CMP is Spring using EJBContext or UserTransaction? The parameter in the Spingconfig is named "userTransactionName". Does it mean that Spring is always using the UserTransaction? In this case it would never run with CMT. Right?

                    Regards.
                    Alex

                    Comment


                    • #11
                      Originally posted by a_schulle
                      Does it mean that Spring is always using the UserTransaction?
                      From a glance at the sources of JtaTransactionManager I would say so.

                      Originally posted by a_schulle
                      In this case it would never run with CMT. Right?
                      I don't know. Perhaps not all app servers are that restrictive.

                      Regards,
                      Andreas

                      Comment


                      • #12
                        serTransaction is prohibited with CMP

                        Did you find an answer to your question: If UserTransaction is prohibited with CMP is Spring using EJBContext or UserTransaction ?

                        If so, can you share it ?

                        Cheers

                        Comment

                        Working...
                        X