java.lang.IllegalArgumentException: object is not an instance of declaring class HandlerMethod details: Controller [$Proxy109] Method [public void com.dpgm.connect.framework.server.remoting.ConsoleHandler.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException] Resolved arguments: [0] [type=org.eclipse.jetty.server.Request] [value=(GET /misc/console)@10144214 org.eclipse.jetty.server.Request@9ac9d6] [1] [type=org.eclipse.jetty.server.Response] [value=HTTP/1.1 200 ]

Spring JIRA | Daniel Gredler | 4 years ago
  1. 0

    As a result of the changes [1] made to RequestMappingHandlerMapping.isHandler(Class) to make it detect both Controller and RequestMapping annotations (see SPR-9374), one of our HttpRequestHandler implementations that was working in 3.1.1 no longer works in 3.1.2: {code} @RequestMapping("/console") @Transactional public class ConsoleHandler implements HttpRequestHandler, ApplicationContextAware { ... @RequestMapping(method = RequestMethod.GET) public void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ... } ... } {code} In 3.1.1, this handler was mapped by the DefaultAnnotationHandlerMapping, which was able to forward HTTP requests to this handler. However, because of the above change, in 3.1.2 this handler is mapped by the RequestMappingHandlerMapping, which throws the following exception when it tries to actually handle an HTTP request: {code} java.lang.IllegalArgumentException: object is not an instance of declaring class HandlerMethod details: Controller [$Proxy109] Method [public void com.dpgm.connect.framework.server.remoting.ConsoleHandler.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException] Resolved arguments: [0] [type=org.eclipse.jetty.server.Request] [value=(GET /misc/console)@10144214 org.eclipse.jetty.server.Request@9ac9d6] [1] [type=org.eclipse.jetty.server.Response] [value=HTTP/1.1 200 ] at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:217) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:558) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:488) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) at org.eclipse.jetty.server.Server.handle(Server.java:350) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442) at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) ... 34 more {code} I'm attaching the debug logs of the server startup + one HTTP request, one log file using Spring 3.1.1 and one log file using Spring 3.1.2. I've massaged the logs a little bit (removed most timestamps, normalized the hashcodes in the toStrings) so that it's easier to see the differences if you diff the files. [1] https://github.com/SpringSource/spring-framework/commit/2fa0e63e5ab84ac964c55a28000104d3855c886c

    Spring JIRA | 4 years ago | Daniel Gredler
    java.lang.IllegalArgumentException: object is not an instance of declaring class HandlerMethod details: Controller [$Proxy109] Method [public void com.dpgm.connect.framework.server.remoting.ConsoleHandler.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException] Resolved arguments: [0] [type=org.eclipse.jetty.server.Request] [value=(GET /misc/console)@10144214 org.eclipse.jetty.server.Request@9ac9d6] [1] [type=org.eclipse.jetty.server.Response] [value=HTTP/1.1 200 ]
  2. 0

    As a result of the changes [1] made to RequestMappingHandlerMapping.isHandler(Class) to make it detect both Controller and RequestMapping annotations (see SPR-9374), one of our HttpRequestHandler implementations that was working in 3.1.1 no longer works in 3.1.2: {code} @RequestMapping("/console") @Transactional public class ConsoleHandler implements HttpRequestHandler, ApplicationContextAware { ... @RequestMapping(method = RequestMethod.GET) public void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ... } ... } {code} In 3.1.1, this handler was mapped by the DefaultAnnotationHandlerMapping, which was able to forward HTTP requests to this handler. However, because of the above change, in 3.1.2 this handler is mapped by the RequestMappingHandlerMapping, which throws the following exception when it tries to actually handle an HTTP request: {code} java.lang.IllegalArgumentException: object is not an instance of declaring class HandlerMethod details: Controller [$Proxy109] Method [public void com.dpgm.connect.framework.server.remoting.ConsoleHandler.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException] Resolved arguments: [0] [type=org.eclipse.jetty.server.Request] [value=(GET /misc/console)@10144214 org.eclipse.jetty.server.Request@9ac9d6] [1] [type=org.eclipse.jetty.server.Response] [value=HTTP/1.1 200 ] at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:217) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:558) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:488) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) at org.eclipse.jetty.server.Server.handle(Server.java:350) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442) at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) ... 34 more {code} I'm attaching the debug logs of the server startup + one HTTP request, one log file using Spring 3.1.1 and one log file using Spring 3.1.2. I've massaged the logs a little bit (removed most timestamps, normalized the hashcodes in the toStrings) so that it's easier to see the differences if you diff the files. [1] https://github.com/SpringSource/spring-framework/commit/2fa0e63e5ab84ac964c55a28000104d3855c886c

    Spring JIRA | 4 years ago | Daniel Gredler
    java.lang.IllegalArgumentException: object is not an instance of declaring class HandlerMethod details: Controller [$Proxy109] Method [public void com.dpgm.connect.framework.server.remoting.ConsoleHandler.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException] Resolved arguments: [0] [type=org.eclipse.jetty.server.Request] [value=(GET /misc/console)@10144214 org.eclipse.jetty.server.Request@9ac9d6] [1] [type=org.eclipse.jetty.server.Response] [value=HTTP/1.1 200 ]
  3. 0

    CC error when using getAvailableItems()

    GitHub | 3 years ago | RikuSS4
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

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

    GitHub | 3 years ago | mibby
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  6. 0

    Java ArrayList Date variable Sorting?

    Stack Overflow | 3 years ago
    java.lang.IllegalArgumentException: object is not an instance of declaring class

  1. Aria Pahlavan 16 times, last 2 weeks ago
  2. kjhdofjosvs 2 times, last 1 month ago
  3. tyson925 2 times, last 1 month ago
  4. kuldeep 2 times, last 2 months 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(Unknown Source)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    4. java.lang.reflect.Method.invoke(Unknown Source)
    4 frames
  3. Spring
    InvocableHandlerMethod.invokeForRequest
    1. org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
    2. org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    2 frames
  4. Spring MVC
    FrameworkServlet.doGet
    1. org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    2. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    3. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    4. org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    5. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    6. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    7. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    8. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    8 frames
  5. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
    2. javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
    2 frames
  6. Jetty
    AsyncHttpConnection.handle
    1. org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:558)
    2. org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:488)
    3. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
    4. org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
    5. org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
    6. org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973)
    7. org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417)
    8. org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
    9. org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907)
    10. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    11. org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:47)
    12. org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
    13. org.eclipse.jetty.server.Server.handle(Server.java:350)
    14. org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
    15. org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
    16. org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)
    17. org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
    18. org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
    18 frames
  7. GWT dev
    SelectChannelEndPoint$1.run
    1. org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
    2. org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
    2 frames
  8. Jetty
    QueuedThreadPool$3.run
    1. org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
    2. org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
    2 frames
  9. Java RT
    Thread.run
    1. java.lang.Thread.run(Unknown Source)
    1 frame