2 Replies Latest reply on Jul 4, 2006 12:14 PM by chrismiles

    Problem with org.jboss.tm.JBossRollbackException using jdbc:

    chrismiles

      This exception is being thrown by my ejbStore method.

      my ejbCreate method is successfully creating a new row in the database but then fails on ejbStore.

      ejbStore calls the following method to do the database work required

       private void storeRow() throws SQLException
       {
       String updateStatement =
       "update Account set " +
       "credit = ?, " +
       "discount = ?, " +
       "openedDate = ?, " +
       "closedDate = ?, " +
       "where id = ?";
       PreparedStatement prepStmt = con.prepareStatement(updateStatement);
      
       prepStmt.setInt(1, this.m_id.intValue());
       prepStmt.setDouble(2, this.m_credit);
       prepStmt.setDouble(3, this.m_discount);
       prepStmt.setDate(4, new java.sql.Date(this.m_openedDate.getTime()));
       prepStmt.setDate(5, new java.sql.Date(this.m_closedDate.getTime()));
      
       int rowCount = prepStmt.executeUpdate();
       prepStmt.close();
      
       if (rowCount == 0)
       {
       throw new EJBException("Storing row for id " + m_id + " failed.");
       }
       }
       }
      


      I get the following error

      ull; nested exception is:
       org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=laptop1/17, BranchQual=, localId=17] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: ejbStore: null); - nested throwable: (org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=laptop1/17, BranchQual=, localId=17] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: ejbStore: null))org.jboss.tm.JBossTransactionRolledbackException: null; nested exception is:
       org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=laptop1/17, BranchQual=, localId=17] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: ejbStore: null); - nested throwable: (org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=laptop1/17, BranchQual=, localId=17] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: ejbStore: null))
      
      
      
       at org.jboss.ejb.plugins.TxInterceptorCMT.throwJBossException(TxInterceptorCMT.java:569)
      
       at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:506)
      
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:361)
      
       at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
      
       at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
      
       at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
      
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
      
       at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:514)
      
       at org.jboss.ejb.Container.invoke(Container.java:975)
      
       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:585)
      
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      
       at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:819)
      
       at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:420)
      
       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:585)
      
       at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      
       at sun.rmi.transport.Transport$1.run(Transport.java:153)
      
       at java.security.AccessController.doPrivileged(Native Method)
      
       at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      
       at java.lang.Thread.run(Thread.java:595)
      
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=laptop1/17, BranchQual=, localId=17] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: ejbStore: null)
      
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
      
       at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:501)
      
       ... 29 more
      
      Caused by: javax.ejb.EJBException: ejbStore: null
      
       at cakeinabox.beans.AccountEJB.AccountBean.ejbStore(AccountBean.java:126)
      
       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:585)
      
       at org.jboss.ejb.plugins.BMPPersistenceManager.invokeEjbStore(BMPPersistenceManager.java:498)
      
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeEjbStore(CachedConnectionInterceptor.java:294)
      
       at org.jboss.ejb.EntityContainer.invokeEjbStore(EntityContainer.java:735)
      
       at org.jboss.ejb.GlobalTxEntityMap$2.invokeEjbStore(GlobalTxEntityMap.java:132)
      
       at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:281)
      
       at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.beforeCompletion(GlobalTxEntityMap.java:345)
      
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
      
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
      
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
      
       ... 30 more
      
      


      I tried

      con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);

      but it is not supported by the database.

        • 1. Re: Problem with org.jboss.tm.JBossRollbackException using j
          chrismiles

          I found the cause of this problem.. was the formatting of my query that was preventing it from running.


          I have some more strange

           private void storeRow() throws SQLException
           {
           String updateStatement =
           "update Account set " +
           "credit = ?, " +
           "discount = ?, " +
           "openedDate = ?, " +
           "closedDate = ?, " +
           "where id = ?";
           PreparedStatement prepStmt = con.prepareStatement(updateStatement);
          
           prepStmt.setInt(1, this.m_id.intValue());
           prepStmt.setDouble(2, this.m_credit);
           prepStmt.setDouble(3, this.m_discount);
           prepStmt.setDate(4, new java.sql.Date(this.m_openedDate.getTime()));
           prepStmt.setDate(5, new java.sql.Date(this.m_closedDate.getTime()));
          
           int rowCount = prepStmt.executeUpdate();
           prepStmt.close();
          
           if (rowCount == 0)
           {
           throw new EJBException("Storing row for id " + m_id + " failed.");
           }
           }
           }
          


          I had to change to the following so the ID is entered into the last space in the query which it was not doing before.

           private void storeRow() throws SQLException
           {
           String updateStatement =
           "update Account set " +
           "credit = ?, " +
           "discount = ?, " +
           "openedDate = ?, " +
           "closedDate = ?, " +
           "where id = ?";
           PreparedStatement prepStmt = con.prepareStatement(updateStatement);
          
           prepStmt.setDouble(1, this.m_credit);
           prepStmt.setDouble(2, this.m_discount);
           prepStmt.setDate(3, new java.sql.Date(this.m_openedDate.getTime()));
           prepStmt.setDate(4, new java.sql.Date(this.m_closedDate.getTime()));
           prepStmt.setInt(5, this.m_id.intValue());
          
           int rowCount = prepStmt.executeUpdate();
           prepStmt.close();
          
           if (rowCount == 0)
           {
           throw new EJBException("Storing row for id " + m_id + " failed.");
           }
           }
           }
          


          But the problem has now changed..........

          ejbStore dies on the same error after I call my create method, but now works fine after I call a finder method?

          public Integer ejbCreate(Integer id, double credit , double discount, java.util.Date openedDate, java.util.Date closedDate)
          
          throws CreateException
           {
           try
           {
           insertRow(id, credit, discount, openedDate, closedDate);
           }
           catch (Exception ex)
           {
           throw new EJBException("ejbRemove: " + ex.getMessage());
           }
          
           this.m_id = id;
           this.m_credit = credit;
           this.m_discount = discount;
           this.m_openedDate = openedDate;
           this.m_openedDate = closedDate;
          
           return this.m_id;
           }


          Its almost as if its trying to sync the bean with persistant storage before the create method has a chance to insert to the database.

          • 2. Re: Problem with org.jboss.tm.JBossRollbackException using j
            chrismiles

            I have just switched everything to postgresql and getting the EXACT same error now....

            what is going on with this??? I cant find anyone with the same problem