Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which exception is thrown in this case.

 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an enterprise bean with bean-managed transaction demarcation calls getRollbackOnly() and setRollbackOnly() methods of the EJBContext interface Which exception is thrown.

Suddenly I came up with this question and do not have book to refer to.
If someone can answer that will be great!

Thanks,
Gemini
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.IllegalStateException

Amol.
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Amol.

I just found the answer in http://java.boot.by/bcd-guide/ch11s04.html
and came here to post reponse to myself :-)

The Container must throw the java.lang.IllegalStateException if an instance of a bean with bean-managed transaction demarcation attempts to invoke the setRollbackOnly() or getRollbackOnly() method of the javax.ejb.EJBContext interface.
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same is true otherway as well..

If an instance of an enterprise bean with container-managed transaction demarcation attempts to invoke the getUserTransaction() method of the EJBContext interface, the Container must throw (and log - MDB ONLY) the java.lang.IllegalStateException.
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats great!!!
Amol.
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Gemini,
Just had an off the corner thought,
Do you mean that Entity and Session beans wont log if IllegalStateException is thrown???
PS: Refer your last post only.
Amol.
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amol,

No. that menas in case of session and entity beans log, and then throw.

Whereas in case of MDB only log. It does not throw exception, since there is no client..

makes sence?

Gemini

Also, In case of stateless sesision bean and MDB there is one more step,
remove the instance that is throwing this exception.
[ March 16, 2005: Message edited by: Gemini Moses ]
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
Here is what I went through,

Since java.lang.IllegalStateException is the System exception, container will take following steps once it occurs.
1) Roll back Tx ( CMT only )
2) Discard Instance
3) Log an error

So as for last posting, Entity and Session beans too log the stuff if IllegalStateException is thrown if EntityContext.getUserTransaction is called by a CMT bean.

And heance that....(log - mdb only) ....made my eyebrows go up (he he).
sure mdb doesnt throw any exception to client(there is not one)....container throws that to the bean.
Amol.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic