aspose file tools*
The moose likes JBoss/WildFly and the fly likes JBOSS 5 UserTransaction not rolling back Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBOSS 5 UserTransaction not rolling back" Watch "JBOSS 5 UserTransaction not rolling back" New topic
Author

JBOSS 5 UserTransaction not rolling back

Aayush Singhal
Ranch Hand

Joined: Jan 06, 2011
Posts: 47
Hi All,

I've got a Third Party Tool (EJB 2.0 in WAR in EAR) deployed on JBoss 5.1 EAP.

There are a couple of datasources configured on the server which I can retrieve using JNDI :



Then I retrieve a USerTransaction using



But when I try to rollback a UserTransaction, it just doesn't roll it back.

for example :



in my scenario, errorFound is true so the above code should rollback the database changes made by callSomeMethod() and callanotherMethod() but it doesn't. These changes are there in the database and the callFinalMEthod is not called hence causing out-of-sync data in my DB.

what is wrong with my code and where else do I need to look up to get it right?

Here's the ds.config file for my datasource :




Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

Where is that UserTransaction lookup happening? On a separate JVM (a.k.a remote client)? Also, what transaction attributes are set on the bean methods?


[My Blog] [JavaRanch Journal]
Aayush Singhal
Ranch Hand

Joined: Jan 06, 2011
Posts: 47
Thanks Jaikiran.

yes. The lookup for UserTransaction is happening at the remote-client, a separate JVM.

How do I find out which transaction attributes are set on the bean methods?? In ejb-jar.xml, for each EJB, <transaction-type> is Container : <transaction-type>Container</transaction-type>? Is there something else that I need to look up??
Aayush Singhal
Ranch Hand

Joined: Jan 06, 2011
Posts: 47
I got this too from ejb-jar.xml :

for read methods :
<trans-attribute>NotSupported</trans-attribute>

for some other read methods :
<trans-attribute>Supports</trans-attribute>

and for the update methods :
<trans-attribute>Required</trans-attribute>

I am calling a couple of read methods (NotSupported and Supports) and a couple of update methods (Required) in my code.

I don't know what these mean?
Aayush Singhal
Ranch Hand

Joined: Jan 06, 2011
Posts: 47
ok I read about the <tran-attribute> in the spec. I am specifically interested in "required" value. It said that if the client is associated with a transaction, then the method is executed in that user transaction. Else a new transaction is started before the method is executed.

I guess, if I am looking up "UserTransaction" in the client code, and then doing a UserTransaction.begin(), then the client is associated with a transaction. So if I rollback the transaction using UserTransaction.rollBack(), this should work... But it is not....

So the problem must be in 'if the client is associated with a transaction'... How do I check that??
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

For JBoss EAP versions lesser than 6, like in your case, see this https://community.jboss.org/wiki/TransactionPropagationWithJBoss
Aayush Singhal
Ranch Hand

Joined: Jan 06, 2011
Posts: 47
Thanks for pointing in the right direction Jaikiran. I went through the mentioned thread and it cleared a lot of things to me. Then I started trying new things and I found out the problem now.

When I do ,

I get ServerVMClientUserTransaction instead of ClientUserTransaction.

Now I triedlooking up the same in a stand-alone POJO client, and it returned me the ClientUserTransaction.

The documentation for ClientUserTransaction says :

Warning: This is only for stand-alone clients that do not have their own transaction service


So the problem is that my client code is also on JBoss 5.1 (GA) which must be having its own transaction service. It is different than the server where the remote EJBs are deployed but it's a JBoss server. So it somehow gives me ServerVMClientUserTransaction instead of ClientUserTransaction. How do I get the ClientUserTransaction from my client JBoss??

I am running the 'default' configuration of JBoss at my client side without making any changes to the Transaction related configs...
Aayush Singhal
Ranch Hand

Joined: Jan 06, 2011
Posts: 47
One of my friends told me that he has worked on a similar problem where the client code was on WebLogic and it worked fine.... Is it a problem because my client is a JBoss server ??? Will it work easily in say Tomcat or WebLogic?? Or is there a way that this can be done in JBoss too....
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

I haven't tried it myself so I can't say what's wrong. See if any of this thread helps https://community.jboss.org/message/766765
Aayush Singhal
Ranch Hand

Joined: Jan 06, 2011
Posts: 47
I am really stuck on this one and this needs to be done...

I was just thinking, is there a way to disable the Transaction Service in the JBoss server. Maybe if I do that in my client JBoss, it may return me the ClientUSerTransaction instead of ServerVMClientUserTransaction??

I couldn't understand much of the structure but I tried to simply remove the transaction-jboss-beans and transaction-service from the 'deploy' folder and jbossts-properties from the 'conf' folder but (as expected) JBoss didn't even start....

Is there a correct way to disable the Transaction Service in JBoss??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBOSS 5 UserTransaction not rolling back
 
Similar Threads
Datasource configuration for Cloudscape
getting errors while running duke's bank application
Transaction Management between two Data Center
Unable to obtain datasource
Problem in deploying multiple EARs in same JBOSS having same application and EJBs in all the EARs