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.