Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-3781

Tomee JTA rollback Failed

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 8.0.6
    • None
    • TomEE Build
    • None
    • tomee 8.0.6,jdk1.8

    Description

      Hello,recently I try to change an old javaee application's webserver.The Application is deploy to OC4J and JDK1.6.Now  we want to upgrade the JDK Version to 1.8,but oc4j don't support jdk 1.8.So wo had tried to change to tomcat.But we found that tomcat don't support JTA.Then I found tomee.But when i test the userTranscation.I found that  the trans can't rollback.I feel that Tomee server hold my failed trans,  the database(ORACLE) can't find these failed data.However i try to redo this trans in webpage,but it  failed because these data already exist in database.but we query these data in database again,wo don't find.When i stop the tomee server,these data can be found in database.

      In tomee.xml,i deploy the database config just like this: 

       

      <Resource id="jdbc/DataSource" type="DataSource">
          jdbcDriver = oracle.jdbc.xa.client.OracleXADataSource
          jtaManaged = true
          initialPoolSize=30
          maxPoolSize=50
          jdbcUrl = 
          password = 
          userName = 
        </Resource>
      

      and in java  application,i use UserTranscation like this:

      //Get UserTrans
      public static UserTransaction getUserTransaction() throws Exception {
         try {
            InitialContext context = new InitialContext();
      
            return (UserTransaction) context
                  .lookup("java:comp/UserTransaction");
         } catch (Exception e) {
            throw new Exception("Error : lookup UserTransaction -- "
                  + e.getMessage());
         }
      }
      
      //get conn
      conn = ServiceBean.getConnection();
      
      //...Query Some data use conn
      UserTransaction trans = null;
      
      try {
        long startTime = System.currentTimeMillis();
        trans = ServiceBean.getUserTransaction();
      
        log.writeLog(6,
                     "transBegin[Start Time:" + new java.util.Date(startTime) +
                     "]");
        trans.begin();
       //...update to database
        trans.commit();
      }catch(Exception ex){
        trans.rollback();
      }
      

      I debug these codes in Idea,and rollback is excuted.Please help to solve the problem.Thanks very much.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            zhili zhi.li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: