troubleshooting Question

unable to catch org.hibernate.StaleObjectStateException in EJB3 JBoss

Avatar of youngzaphod
youngzaphod asked on
Java App ServersWeb ApplicationsJava EE
3 Comments1 Solution1157 ViewsLast Modified:
Hi there.

I am developing an EJB3 application in Jboss 5 with a db connector to MySQL.
I am trying to prevent simultaneous writes of two or more transactions on the same entities by using a @Version annotated field inside the affected entity bean.
If I test it by forcing two transactions to simulataneously read the same entities and then write them I get a StaleObjectException and one transaction rolls back. That's fine!
But, I am unable to catch this exception with a try{...} catch(Exception e)... block around the method that starts the transaction. How can I catch a RollbackException? I don't want to propagate this exception back to the client I just want to restart the transaction.

Please help! Thanks.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros