0 Replies Latest reply on Mar 20, 2003 8:20 PM by sunnus

    Why my transaction doesn't work?

    sunnus

      I have write a little example to test JTA of jboss, but it doesn't work.
      Could anyone can help me?
      try {
      Context ctx=new InitialContext();
      UserTransaction usrTran=null;
      TranTestHome tranTestHome = (TranTestHome) PortableRemoteObject.narrow(ctx.lookup("TranTest"), TranTestHome.class);
      TranTest tranTest=tranTestHome.create();
      usrTran=(UserTransaction)ctx.lookup("UserTransaction");
      int i=0;
      usrTran.begin();
      System.out.println("Transaction Begin");
      tranTest.addNum(100);
      usrTran.rollback();
      System.out.println("The Number is:"+tranTest.getNum());
      } catch (Exception e) {
      System.out.println(e.getMessage());
      }

      addNum(int i) is a function for adding when invoked, I want to rollback the adding but it not work, why this happened?

      Thanks.