*
The moose likes EJB and other Java EE Technologies and the fly likes Releasing resources in a stateful session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Releasing resources in a stateful session bean" Watch "Releasing resources in a stateful session bean" New topic
Author

Releasing resources in a stateful session bean

Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
Hello,I'm developing an EJB2 Session bean that keeps a JMSConnection open while it's active. I'm closing the connection in ejbRemove() and ejbPassivate(), but is that enough? As I understand it, neither of these callbacks are called if a system exception is thrown, so will the Resource Manager know to release the connection if the bean is destroyed that way? Or should all my methods have a try-catch for RuntimeExceptions and close the connection in the catch block before rethrowing the exception?

Thank you,
Yuriy
Rikard Qvarforth
Ranch Hand

Joined: Jul 10, 2001
Posts: 107
well in session bean the ejbActivate and ejbPassivate methods is where you should aqureire and relese resources before the bean is passivated or activated by the container. For runtime exception you cant be sure of so make your implemention code in theese callbacks(hookmethods) and you should be safe

Regards Rikard
 
wood burning stoves
 
subject: Releasing resources in a stateful session bean
 
Similar Threads
oci8 driver problem.
EJB HELP
RollbackException and PersistentContext
Transaction Rollback not rolling back the Database updates !!
catching and throwing exceptions