I would like to create an exception handler for the specific case that happens when an EJB client application loses the connection with the application server. The code we are creating is able to handle the client application in user friendly way to try to reconnect to the same server or another server in a fail-over environment. By "losing the connection" I mean anything the requires reconnecting. The cause maybe a network problem, server lock-up, service down, etc.
Here is an idea of what we are looking for (client code):
private void doSomething() throws RecoverableException {
//(...)
BusinessRemoteEJB ejb=ctx.lookup("BusinessRemoteEJB");
try {
List<product> list=ejb.getProducts();
//(...)
} catch (EJBException e){
Exception e = e.getCausedByException();
//Here is what I'm looking for: some excpetion that indicates a connection problem
if(e !=null && e instanceof EJBConnectionException){
//This will be catched in a proper place to try to reconnect
throw new RecoverableException(e);
} else {
//If it is any other excpetion, just let it work up the stack
throw e;
}
Of course EJBConnectionException doesn't exist. Is there anything like it?
We are using OpenEJB 1.4 (EJB 3.x compliant). However, we want to use an exception handler that could be used across different application servers if possible.
Another thing is that some application servers provide some kind of fail over mechanisms but our requirements are a little specific and we can implement it directly in the client code.