throw new RemoteException("Handle does not hold a " + remoteInterface.getName(), e);
}
} else {
try {
Object handleKey = handle.getPrimaryKey();
RpcContainer container = (RpcContainer) ejbDeployment.getContainer();
result = container.invoke(ejbDeployment.getDeploymentId(), interfaceType, method.getDeclaringClass(), method, arguments, handleKey);
} catch (OpenEJBException e) {
Throwable cause = e.getCause();
if (cause instanceof Exception) {
Exception exception = (Exception) cause;
return Util.writeUserException(method, reply, exception);
}
throw cause;
}
}
} catch (RemoveException e) {
return Util.writeUserException(method, reply, e);
}
result = null;
} else if (method.equals(REMOVE_W_KEY)) {
try {
ejbDeployment.getEJBHome().remove(arguments[0]);
result = null;
} catch (RemoveException e) {
return Util.writeUserException(method, reply, e);
}
} else {
throw new UnsupportedOperationException("unknown method: " + method);
}
} else {
try {
RpcContainer container = (RpcContainer) ejbDeployment.getContainer();
result = container.invoke(ejbDeployment.getDeploymentId(), interfaceType, method.getDeclaringClass(), method, arguments, primaryKey);
// some methods like create() or find* return ProxyInfo objects. We need to
// turn those into real EJB remote references.
if (result instanceof ProxyInfo || method.getName().startsWith("find")) {
result = createProxy(result);
}