I have a lot of problems with deadlocks and I have tried a lot of different configuration and none have worked (I will soon post some questions about this). So my new strategy is to rollback and retry the transactions which fails. However, I have realized that I do not understand everything about transactions.

Questions:Is this the correct way to handle the transaction rollback?I hope I don't have to call a specific method to actually perform the rollback?I also read somewhere on this forum that JBoss automatically retries transaction when deadlock occurs, is that true?

Anyway, the code above seems to work in most cases.

Attempt two:

I don't to want to catch the exceptions in the servlet so I moved the code above to a new method in the session ejb called testRequest(), which the servlet invokes. testRequest() then calls the original request() method.

I used "Required" for testRequest() and "RequiresNew() for request(). My thought was that a new transaction would be created and that would be the transaction that would be rolled back in case of problems.

This didnt work as I expected, the transaction rolled back but it is never restarted , instead it stayed in the rollback state. I tried to invoke context.getRollbackOnly() in testRequest() and it returned "True". So I guess that the transaction which is started when the servlet calls testRequest() is rolled back as well, I thought that only the second transaction which is created when request() is called would rollback..

Questions:Will a rollback propagate all the way back to the original transaction if "RequiresNew" is used?Is there a way to catch and retry the transaction rollbacks in the actual session bean instead of in the servlet?