List of usage examples for javax.ejb EJBAccessException getCause
public synchronized Throwable getCause()
From source file:ome.client.Interceptor.java
public Object invoke(MethodInvocation arg0) throws Throwable { Object toReturn = null;//from w w w. j av a 2 s . c o m Throwable toThrow = null; try { SecurityAssociation.setPrincipal(principal); toReturn = arg0.proceed(); } catch (final Throwable t) { toThrow = t; if (t instanceof RootException) { // This is what we're expecting. } else if (t instanceof javax.ejb.EJBAccessException) { javax.ejb.EJBAccessException ejb = (javax.ejb.EJBAccessException) t; if (ejb.getCause() instanceof LoginException) { LoginException login = (LoginException) ejb.getCause(); if (login.getCause() instanceof org.jboss.util.NestedSQLException) { toThrow = new OutOfService( "Database appears to be down, " + "improperly configured, or corrupted.", t); } } else { // These are allowed to be thrown. } } else if (t instanceof ClassNotFoundException) { if (t.getMessage().contains("org.postgresql.util.PSQLException")) { toThrow = new OutOfService("Database appears to be down, but no exception is " + "available since org.postgresql.util.PSQLException " + "is not on your classpath", t); } else { toThrow = new OutOfService("Client appears improperly configured.", t); } } else if (t instanceof JndiLookupFailureException) { toThrow = new OutOfService("Cannot find service. Is the server running?"); } else { toThrow = new OutOfService("Error during invocation. " + "Most likely server version does " + "not match client version", t); } } finally { SecurityAssociation.setPrincipal(unknown); } if (toThrow != null) { throw toThrow; } else { return toReturn; } }