只有远程接口的 EJB 3.1 会话 Bean 上的 JAX-RS

JAX-RS on EJB 3.1 Session Bean which only has Remote Interface

我可以在只有远程接口的 EJB 3.1 会话 bean 上使用 @Path 等 JAX-RS 注释吗?

这个有效:

@Path("/service")
@Stateless
public class ServiceOne {
    @POST
    @Path("/foo")
    public Response foo() {
        return Response.ok().build();
    }
}

但是,如果我添加一个远程接口...

@Remote
public interface ServiceOneRemote {
    Response foo();
}

@Path("/service")
@Stateless
public class ServiceOne implements ServiceOneRemote {
    @POST
    @Path("/foo")
    public Response foo() {
        return Response.ok().build();
    }
}

...我得到一个 NotSerializableException

java.io.NotSerializableException: org.jboss.resteasy.core.ServerResponse
    org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253)
    org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:128)
    org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:295)
    org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:286)
    org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:258)
    org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:184)
    org.jboss.ejb.client.EJBObjectInterceptor.handleInvocation(EJBObjectInterceptor.java:58)
    org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
    org.jboss.ejb.client.EJBHomeInterceptor.handleInvocation(EJBHomeInterceptor.java:83)
    org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
    org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:42)
    org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
    org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125)
    org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
    org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)
    org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)
    org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)
    org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
    com.sun.proxy.$Proxy88.foo(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:483)
    org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:168)
    org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
    org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
    org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
    org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:541)
    org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:523)
    org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:125)
    org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

从类似 Implementing RESTful views of an EJB with local interfaces 的文章中,我得到的印象是 JAX-RS 仅适用于具有本地接口的会话 bean。但是我找不到任何明确说明这是不可能的资源。

我做错了什么吗?或者这是不可能的?

顺便说一句:我是 运行 一个 JBoss EAP 6.4 应用程序服务器。

这是不可能的。在 JSR-339(RESTful Web 服务的 JavaTM API)规范中,说明如下:

JAX-RS annotations can be applied to methods in an EJB’s local interface or directly to methods in a no-interface EJB.