This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

illegalstateexception

 
Ben Hsu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can someone clarify when you will get an IllegalStateException and when you will get a Remote/Ejb exception? It seems one case is when you need a transaction to call a method and there is no transaction, or when BMT methods are used in CMT beans or vice versa. Are there any other situations?

Thank you
 
Balaji Anand
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the spec there are somethings related to CMP beans. I havent read it yet so cant explain it now. but refer to chapter 10 of the spec.
 
Greg Charles
Sheriff
Posts: 3002
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IllegalStateException is usually associated with calling a method on the EJB context that you shouldn't be calling. For example, you can't call getUserTransaction() from a CMT bean. You can't call getCallerPrincipal() from a Message-Driven Bean.

There are several ways you could get a RemoteException. There could be a failure in the network communication. The bean method could throw an EJBException or any other system exception (i.e., one descended from RuntimeException or Error), which the container will wrap in a RemoteException and rethrow to the client. In addition, NoSuchObjectException, TransactionRequiredException, and TransactionRolledbackException are all kinds of RemoteExceptions that can be thrown under various conditions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic