} catch (Throwable t) {
replyWithFatalError(out, t, "Bad request");
return;
}
SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
try {
Object clientIdentity = req.getClientIdentity();
if (clientIdentity != null) securityService.associate(clientIdentity);
} catch (Throwable t) {
replyWithFatalError(out, t, "Client identity is not valid");
return;
}
CallContext call = null;
BeanContext di = null;
try {
di = this.daemon.getDeployment(req);
} catch (RemoteException e) {
replyWithFatalError(out, e, "No such deployment");
return;
/*
logger.warn( req + "No such deployment: "+e.getMessage());
res.setResponse( EJB_SYS_EXCEPTION, e);
res.writeExternal( out );
return;
*/
} catch (Throwable t) {
replyWithFatalError(out, t, "Unkown error occured while retrieving deployment");
return;
}
// Need to set this for deserialization of the body
ClassLoader classLoader = di.getBeanClass().getClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try {
req.getBody().readExternal(in);
} catch (Throwable t) {
replyWithFatalError(out, t, "Error caught during request processing");
return;
}
try {
call = CallContext.getCallContext();
call.setEJBRequest(req);
call.setBeanContext(di);
} catch (Throwable t) {
replyWithFatalError(out, t, "Unable to set the thread context for this request");
return;
}
boolean respond = true;
try {
switch (req.getRequestMethod()) {
// Remote interface methods
case RequestMethodConstants.EJB_OBJECT_BUSINESS_METHOD:
doEjbObject_BUSINESS_METHOD(req, res);
updateServer(req, res);
break;
// Home interface methods
case RequestMethodConstants.EJB_HOME_CREATE:
doEjbHome_CREATE(req, res);
updateServer(req, res);
break;
// Home interface methods
case RequestMethodConstants.EJB_HOME_METHOD:
doEjbHome_METHOD(req, res);
updateServer(req, res);
break;
case RequestMethodConstants.EJB_HOME_FIND:
doEjbHome_FIND(req, res);
updateServer(req, res);
break;
// javax.ejb.EJBObject methods
case RequestMethodConstants.EJB_OBJECT_GET_EJB_HOME:
doEjbObject_GET_EJB_HOME(req, res);
updateServer(req, res);
break;
case RequestMethodConstants.EJB_OBJECT_GET_HANDLE:
doEjbObject_GET_HANDLE(req, res);
updateServer(req, res);
break;
case RequestMethodConstants.EJB_OBJECT_GET_PRIMARY_KEY:
doEjbObject_GET_PRIMARY_KEY(req, res);
updateServer(req, res);
break;
case RequestMethodConstants.EJB_OBJECT_IS_IDENTICAL:
doEjbObject_IS_IDENTICAL(req, res);
updateServer(req, res);
break;
case RequestMethodConstants.EJB_OBJECT_REMOVE:
doEjbObject_REMOVE(req, res);
break;
// javax.ejb.EJBHome methods
case RequestMethodConstants.EJB_HOME_GET_EJB_META_DATA:
doEjbHome_GET_EJB_META_DATA(req, res);
updateServer(req, res);
break;
case RequestMethodConstants.EJB_HOME_GET_HOME_HANDLE:
doEjbHome_GET_HOME_HANDLE(req, res);
updateServer(req, res);
break;
case RequestMethodConstants.EJB_HOME_REMOVE_BY_HANDLE:
doEjbHome_REMOVE_BY_HANDLE(req, res);
break;
case RequestMethodConstants.EJB_HOME_REMOVE_BY_PKEY:
doEjbHome_REMOVE_BY_PKEY(req, res);
break;
case RequestMethodConstants.FUTURE_CANCEL:
doFUTURE_CANCEL_METHOD(req, res);
break;
}
} catch (org.apache.openejb.InvalidateReferenceException e) {
res.setResponse(ResponseCodes.EJB_SYS_EXCEPTION, new ThrowableArtifact(e.getRootCause()));
} catch (org.apache.openejb.ApplicationException e) {
res.setResponse(ResponseCodes.EJB_APP_EXCEPTION, new ThrowableArtifact(e.getRootCause()));
} catch (org.apache.openejb.SystemException e) {
res.setResponse(ResponseCodes.EJB_ERROR, new ThrowableArtifact(e.getRootCause()));
logger.error(req + ": OpenEJB encountered an unknown system error in container: ", e);
} catch (Throwable t) {
replyWithFatalError(out, t, "Unknown error in container");
respond = false;
} finally {
if (logger.isDebugEnabled()) {
//The req and res toString overrides are volatile
try {
logger.debug("EJB REQUEST: " + req + " -- RESPONSE: " + res);
} catch (Throwable t) {
//Ignore
}
}
if (respond) {
try {
res.writeExternal(out);
} catch (Throwable t) {
logger.error("Failed to write EjbResponse", t);
}
}
try {
securityService.disassociate();
} catch (Throwable t) {
logger.warning("Failed to disassociate security", t);
}
call.reset();