res.setResponseCode(ResponseCodes.JNDI_NAMING_EXCEPTION);
res.setResult(new ThrowableArtifact(e));
return;
}
BaseEjbProxyHandler handler;
try {
handler = (BaseEjbProxyHandler) ProxyManager.getInvocationHandler(object);
} catch (final Exception e) {
try {
final Field field = object.getClass().getDeclaredField("invocationHandler");
field.setAccessible(true);
handler = (BaseEjbProxyHandler) field.get(object);
} catch (final Exception e1) {
// Not a proxy. See if it's serializable and send it
if (object instanceof java.io.Serializable) {
res.setResponseCode(ResponseCodes.JNDI_OK);
res.setResult(object);
return;
} else {
res.setResponseCode(ResponseCodes.JNDI_NAMING_EXCEPTION);
final NamingException namingException = new NamingException("Expected an ejb proxy, found unknown object: type=" +
object.getClass().getName() +
", toString=" +
object);
res.setResult(new ThrowableArtifact(namingException));
return;
}
}
}
final ProxyInfo proxyInfo = handler.getProxyInfo();
final BeanContext beanContext = proxyInfo.getBeanContext();
final String deploymentID = beanContext.getDeploymentID().toString();
updateServer(req, res, proxyInfo);