public EJBObject getEJBObject() throws IllegalStateException { ThreadContext threadContext = ThreadContext.getThreadContext(); DeploymentInfo di = threadContext.getDeploymentInfo(); if (di.getRemoteInterface() == null) { throw new IllegalStateException("EJB " + di.getDeploymentID() + " does not have a remote interface"); } EjbObjectProxyHandler handler = new EntityEjbObjectHandler(di.getContainer().getDeploymentInfo(di.getDeploymentID()), threadContext.getPrimaryKey(), InterfaceType.EJB_OBJECT, new ArrayList<Class>()); try { Class[] interfaces = new Class[]{di.getRemoteInterface(), IntraVmProxy.class}; return (EJBObject) ProxyManager.newProxyInstance(interfaces, handler); } catch (IllegalAccessException iae) { throw new InternalErrorException("Could not create IVM proxy for " + di.getRemoteInterface() + " interface", iae); } }