这是我的SLSB:
@Stateless(name = "FinderEJB")
@Path("/")
public class Finder implements FinderLocal {
@Path("/simple")
@GET
public String simple() {
return "works";
}
}
界面是:
@Local
public interface FinderLocal {
public String simple();
}
当我尝试打开网址/simple
时,这就是我在Glassfish服务器日志中获得的内容:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:156)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:208)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:115)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:75)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:115)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:67)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:775)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:740)
[...]
它是什么?我设法找到了一个关于它的主题at nabble.com,但它没有解决方案..
答案 0 :(得分:2)
将EJB / JAX-RS与接口和实现混合,我也遇到了这些错误:
java.lang.IllegalArgumentException: object is not an instance of declaring class
它没有使用glassfish V3和3.1,但它适用于tomcat 7 / jersey 1.5
我提交了测试用例的错误: http://java.net/jira/browse/GLASSFISH-16199
答案 1 :(得分:0)
我有类似的问题;事实证明这是web.xml中的配置错误。
请务必使用以下内容:
<servlet>
<servlet-name>Jersey Servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>my.company.product.rs</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
希望有所帮助
答案 2 :(得分:0)
问题是Glassfish(在其默认安装中)不支持EJB 3.1。您有to upgrade it才能获得此类支持。