Is there an exception that can be caught when an EJB client loses connection with an application server?

I would like to create an exception handler for a specific case that happens when an EJB client application loses connection with the application server. The code we create is able to process the client application in a way convenient for the user to try to connect to the same server or another server in a failed environment. “Lost Communication” means anything that requires reconnection. The cause may be a network problem, server blocking, down service, etc.

Here is the 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, an EJBConnectionException does not exist. Is there anything similar?

OpenEJB 1.4 ( EJB 3.x). , , , .

, , , .

+3
1

@Remote, java.rmi.Remote, . , java.rmi.RemoteException. . java.rmi.Remote EJBException. , , EJBException, EJBException .

@Remote
public interface OrangeRemote extends java.rmi.Remote {

    public void doSomething() throws RemoteException;
}

@Stateless
public class OrangeBean implements OrangeRemote {

    @Override
    public void doSomething() {
        //...
    }
}

, bean RemoteException throws. Java , EJB . RemoteException bean , - .

+7

All Articles