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?
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
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop