• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In a Roll back EJB exception is thrown

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am using JPA with hibernate in a stateless session been and and that bean is called from a servlet. I am using CMP and when ever a roll back occurs it is thrown back to the servlet as a EJBException. My problem is, since EJBException is thrown for other reasons as well, how to figure out whether it was thrown for a roll back or some other reason. At the same time, can't we catch the Transaction aborted exception in the EJB. I tried using RuntimeException in the catch clause, but it didn't work. Anticipating a reply. Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using CMP and when ever a roll back occurs it is thrown back to the servlet as a EJBException

That's the wrong way roung, isn't is? The EJBException causes a transaction to be rolled back, not a rollback causing an EJBException? Or am I misunderstanding you?


since EJBException is thrown for other reasons as well, how to figure out whether it was thrown for a roll back or some other reason

What other reason causes it to be thrown?
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for the reply. Yes good point, EJBException is thrown and then roll back happens. That's the way it should be. But the problem I am having is, when I try to add a record with the same primary key, I get this problem. I really don't know what to do, meaning, what exception which I need to capture. I am using JPA with hibernate.

Thanks and expecting a reply soon.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic