3 Replies Latest reply on Jul 17, 2004 4:39 AM by Alexey Loubyansky

    catch JBossTransactionRolledBackException during optimistic

    Marek Neumann Novice

      During my tests with the JDBCOptimisticLock strategy (which worked btw), I encountered a problem: how can I catch the exception thrown by JBoss when an update error occured:

      [java] JBossTransactionRolledbackException was: org.jboss.tm.JBossTransactionRolledbackException: null; nested exception is:
      [java] org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=HERTZ//186, BranchQual=] sta
      tus=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0, id=1); - nested thro
      wable: (org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=HERTZ//186, BranchQual=] status=STAT
      US_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0, id=1)

      I am not able to catch this neither on the server nor on the client.

      Any hints?

      Thanks, marek

        • 1. Re: catch JBossTransactionRolledBackException during optimis
          Alexey Loubyansky Master

          First, JDBCOptimisticLock class is deprecated. Just use NoLock and optimistic locking config in jbosscmp-jdbc.xml

          You could perform the work that might be rolled back due to optimistic locking failure in a method with RequiresNew transaction attribute, catch the exception in the method that called the method with RequiresNew and react appropriatly.

          • 2. Re: catch JBossTransactionRolledBackException during optimis
            David Newbie

            I am having the same problem

            2004.07.16 08:58:30.609 EDT INFO [STDOUT] org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=DBOON1//197, BranchQual=] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0id=com.isopia.ilms.ejb.entityBeans.productGroup.ProductGroupPK@c808b72c[parentProductId=20113,childProductId=9388,startDate=2004-07-16 12:58:30.546)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:413)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.jboss.tm.TxManager.commit(TxManager.java:141)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:126)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at com.isopia.ilms.ui.common.UserTX.commitTX(UserTX.java:76)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at com.isopia.ilms.ui.msi.PackageJB.processForm(PackageJB.java:945)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.jsp.msi.pp.package_005fcreate_jsp._jspService(package_005fcreate_jsp.java:198)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at com.elementk.util.RequestTimingFilter.doFilter(RequestTimingFilter.java:49)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at com.elementk.security.servlet.LmnkSecurityFilter.doFilter(LmnkSecurityFilter.java:110)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
            2004.07.16 08:58:30.609 EDT INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
            2004.07.16 08:58:30.625 EDT INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
            2004.07.16 08:58:30.625 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
            2004.07.16 08:58:30.625 EDT INFO [STDOUT] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:509)
            2004.07.16 08:58:30.625 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
            2004.07.16 08:58:30.625 EDT INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
            2004.07.16 08:58:30.703 EDT INFO [STDOUT] at com.elementk.util.valve.RequestCollectorValve.invoke(RequestCollectorValve.java:96)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at com.elementk.util.valve.RequestEncodingValve.invoke(RequestEncodingValve.java:73)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:211)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:309)
            2004.07.16 08:58:30.796 EDT INFO [STDOUT] at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:387)
            2004.07.16 08:58:30.921 EDT INFO [STDOUT] at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673)
            2004.07.16 08:58:30.921 EDT INFO [STDOUT] at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:615)
            2004.07.16 08:58:30.921 EDT INFO [STDOUT] at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786)
            2004.07.16 08:58:30.921 EDT INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
            2004.07.16 08:58:30.921 EDT INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)
            2004.07.16 08:58:30.921 EDT INFO [STDOUT] Caused by: javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0id=com.isopia.ilms.ejb.entityBeans.productGroup.ProductGroupPK@c808b72c[parentProductId=20113,childProductId=9388,startDate=2004-07-16 12:58:30.546
            2004.07.16 08:58:30.921 EDT INFO [STDOUT] at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:155)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:627)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:421)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:387)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:714)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.ejb.GlobalTxEntityMap.synchronizeEntities(GlobalTxEntityMap.java:149)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapSynchronize.beforeCompletion(GlobalTxEntityMap.java:215)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1308)
            2004.07.16 08:58:31.156 EDT INFO [STDOUT] at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:347)
            2004.07.16 08:58:31.343 EDT INFO [STDOUT] ... 49 more
            
            


            I have made the change you suggested, with using NoLock and <optimistic-locking/> in our jbosscmp-jdbc.xml. However we are still getting the same error. This situation seems unique in that the transaction iis a UserTransaction.




            • 3. Re: catch JBossTransactionRolledBackException during optimis
              Alexey Loubyansky Master

              As described how to catch rollback exception in my previous post in this thread.