java.lang.IllegalArgumentException: object is not an instance of declaring class

java.net | 4 months ago
  1. 0

    Hello, I'm have the following error when deploying a JAX-RS / EJB service in a war or ear. The exception : "java.lang.IllegalArgumentException: object is not an instance of declaring class" Java code : {code} @Local @Remote public interface Echo { String echo(String message); } @Stateless @Path("/echo") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public class EchoImpl implements Echo { @GET @Path("/send") public String echo(@QueryParam("message") final String message) { return message; } } public class RestResourcesApp extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> s = new HashSet<Class<?>>(); s.add(EchoImpl.class); return s; } } {code} web.xml {code} <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>restEjb</display-name> <servlet> <servlet-name>RestResourcesServlet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>test.RestResourcesApp</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>RestResourcesServlet</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> {code} http://localhost:8080/restEjb/rest/echo/send?message=hello works on tomcat 7.x, but failed on glassfish v3, V3.1 Please find attach war test case. If you removed "implements Echo" in class EchoImpl , it will works Regards,

    Java.net JIRA | 6 years ago | jraduget
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    Hello, I'm have the following error when deploying a JAX-RS / EJB service in a war or ear. The exception : "java.lang.IllegalArgumentException: object is not an instance of declaring class" Java code : {code} @Local @Remote public interface Echo { String echo(String message); } @Stateless @Path("/echo") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public class EchoImpl implements Echo { @GET @Path("/send") public String echo(@QueryParam("message") final String message) { return message; } } public class RestResourcesApp extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> s = new HashSet<Class<?>>(); s.add(EchoImpl.class); return s; } } {code} web.xml {code} <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>restEjb</display-name> <servlet> <servlet-name>RestResourcesServlet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>test.RestResourcesApp</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>RestResourcesServlet</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> {code} http://localhost:8080/restEjb/rest/echo/send?message=hello works on tomcat 7.x, but failed on glassfish v3, V3.1 Please find attach war test case. If you removed "implements Echo" in class EchoImpl , it will works Regards,

    Java.net JIRA | 6 years ago | jraduget
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  4. 0

    [#GLASSFISH-16199] IllegalArgumentException: object is not an instance of declaring class - on a REST / EJB Service

    java.net | 4 months ago
    java.lang.IllegalArgumentException: object is not an instance of declaring class

  1. kuldeep 2 times, last 2 months ago
  2. Aria Pahlavan 16 times, last 3 weeks ago
  3. kjhdofjosvs 2 times, last 1 month ago
  4. tyson925 2 times, last 1 month ago
  5. aldrinleal 1 times, last 5 months ago
6 more registered users
72 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalArgumentException

    object is not an instance of declaring class

    at sun.reflect.NativeMethodAccessorImpl.invoke0()
  2. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    4 frames
  3. Jersey
    WebApplicationImpl.handleRequest
    1. com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:167)
    2. com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:70)
    3. com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:279)
    4. com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
    5. com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:86)
    6. com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
    7. com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:74)
    8. com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1347)
    9. com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1279)
    10. com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1229)
    11. com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1219)
    11 frames
  4. Jersey
    ServletContainer.service
    1. com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:419)
    2. com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    3. com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
    3 frames
  5. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    1 frame
  6. Glassfish Core
    StandardPipeline.invoke
    1. org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
    2. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    3. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    4. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    5. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    5 frames
  7. Glassfish
    PESessionLockingStandardPipeline.invoke
    1. com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    2. com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    2 frames
  8. Glassfish Core
    CoyoteAdapter.service
    1. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    2. org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
    3. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
    3 frames
  9. Kernel Classes
    ContainerMapper.service
    1. com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
    1 frame
  10. Grizzly WS
    AbstractThreadPool$Worker.run
    1. com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    2. com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    3. com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    4. com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    5. com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    6. com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    7. com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    8. com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    9. com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    10. com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    11. com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    12. com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    13. com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    13 frames
  11. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:680)
    1 frame