PDA

View Full Version : Closing Application Context



Richard.F
Aug 26th, 2005, 03:57 AM
Hi,

I have a slsb extending AbstractStatelessSessionBean deployed to JBoss4.0.2. When it throws an exception from a remote method I notice from the logs that the Application Context is closed.

Is this standard behaviour? Are there any alternative approaches to avoid this?

Any help greatly appreciated, thanks in advance.

Ric.

Chris
Aug 30th, 2005, 06:20 PM
Could this be because JBoss removes the bean from the pool when a remote exception occurs. If you have used the defaults when sub-classing, each bean has its own context, which will therefore be closed, see:

http://static.springframework.org/spring/docs/1.2.x/reference/ejb.html#ejb-implementation

for a singleton based context, which is also more performant. Note that you need to set one of your beans to have min instances in the pool to >0 to keep the context permenently in the JVM, otherwise during periods of inactivity your container may decide to remove all bean from the pool, which causes the context to be closed.

Chris

Richard.F
Sep 2nd, 2005, 04:03 AM
The Bean was throwing an exception that subclassed runtime exception. I guess this caused JBoss to unload the Bean and hence the context. Changing the exception to a checked exception meant that the remote exception was thrown but the Bean was not unloaded, so the context was not reloaded on next request.