org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch

Spring JIRA | Oliver Siegmar | 5 years ago
  1. 0

    Consider the following simplified example: {code} @Controller @RequestMapping("/foo") @SessionAttributes("command") public class FooController { @RequestMapping("/page1") public ModelAndView page1() { return new ModelAndView("foo", "command", new FooCommand()); } } @Controller @RequestMapping("/bar") @SessionAttributes("command") public class BarController { @RequestMapping("/page2") public String page2(@ModelAttribute("command") final BarCommand command) { return "bar"; } } {code} So you have two controllers using the same name for a session bound model attribute. Now call /foo/page1 and then /bar/page2 the following exception will be arise: {noformat} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) ~[servlet-api.jar:na] at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) ~[servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) [catalina.jar:7.0.22] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) [catalina.jar:7.0.22] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) [catalina.jar:7.0.22] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.22] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) [catalina.jar:7.0.22] at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200) [tomcat-coyote.jar:7.0.22] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) [tomcat-coyote.jar:7.0.22] at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) [tomcat-coyote.jar:7.0.22] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_01] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_01] at java.lang.Thread.run(Thread.java:722) [na:1.7.0_01] Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_01] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_01] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_01] at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_01] at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) ~[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] ... 71 common frames omitted {noformat} This can be really hard to track error, when the application is not as simple es the example above. I understand that an exception is thrown, but the message should be something like "Can't bind FooCommand found in session to handler method BarController#page2(BarCommand). You may have used session model attribute 'command', ambiguously".

    Spring JIRA | 5 years ago | Oliver Siegmar
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch
  2. 0

    Consider the following simplified example: {code} @Controller @RequestMapping("/foo") @SessionAttributes("command") public class FooController { @RequestMapping("/page1") public ModelAndView page1() { return new ModelAndView("foo", "command", new FooCommand()); } } @Controller @RequestMapping("/bar") @SessionAttributes("command") public class BarController { @RequestMapping("/page2") public String page2(@ModelAttribute("command") final BarCommand command) { return "bar"; } } {code} So you have two controllers using the same name for a session bound model attribute. Now call /foo/page1 and then /bar/page2 the following exception will be arise: {noformat} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) ~[servlet-api.jar:na] at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) ~[servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) [catalina.jar:7.0.22] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) [catalina.jar:7.0.22] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) [catalina.jar:7.0.22] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) [catalina.jar:7.0.22] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.22] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) [catalina.jar:7.0.22] at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200) [tomcat-coyote.jar:7.0.22] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) [tomcat-coyote.jar:7.0.22] at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) [tomcat-coyote.jar:7.0.22] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_01] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_01] at java.lang.Thread.run(Thread.java:722) [na:1.7.0_01] Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_01] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_01] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_01] at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_01] at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) ~[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669) ~[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE] ... 71 common frames omitted {noformat} This can be really hard to track error, when the application is not as simple es the example above. I understand that an exception is thrown, but the message should be something like "Can't bind FooCommand found in session to handler method BarController#page2(BarCommand). You may have used session model attribute 'command', ambiguously".

    Spring JIRA | 5 years ago | Oliver Siegmar
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch
  3. 0

    Argument type mismatch error in maven spring mvc

    Stack Overflow | 3 years ago | ntstha
    java.lang.IllegalArgumentException: argument type mismatch
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    argument type mismatch in spring

    Stack Overflow | 4 years ago | sainath reddy
    java.lang.IllegalArgumentException: argument type mismatch
  6. 0

    I have a controller with a methods defined as such @RequestMapping(value = "/services/{serviceName}/scenes/", method = RequestMethod.POST) public void addScene(@PathVariable("serviceName") String serviceName, @RequestBody SceneTO receivedSceneTO, HttpServletRequest request, HttpServletResponse response) { ... } It is designed to be able to POST "SceneTO"s to. I have made a smart custom message converters so people can submit VideoScenes, AudioScenes, TextScenes etc. The convertor will create the appropriate SceneTO inheriting object. However, i get this exception: java.lang.IllegalArgumentException: argument type mismatch 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 org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:71) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450) If I change my convertor to ONLY create SceneTO objects (instead of an inheriting one), it works fine. The method clearly does not support inheritance We can currently work around the problem by doing this @RequestMapping(value = "/services/{serviceName}/scenes/video", method = RequestMethod.POST) public void addScene(@PathVariable("serviceName") String serviceName, @RequestBody VideoTO receivedSceneTO, HttpServletRequest request, HttpServletResponse response) and @RequestMapping(value = "/services/{serviceName}/scenes/audio", method = RequestMethod.POST) public void addScene(@PathVariable("serviceName") String serviceName, @RequestBody AudioTO receivedSceneTO, HttpServletRequest request, HttpServletResponse response) But it does seem less clean and results in much duplicated code. Allowing inheritance would seem much more elegant. (I imagine some other people may want interfaces as well)

    Spring JIRA | 7 years ago | Bruce Lowe
    java.lang.IllegalArgumentException: argument type mismatch

  1. Aria Pahlavan 16 times, last 3 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

    argument type mismatch

    at sun.reflect.NativeMethodAccessorImpl.invoke0()
  2. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.7.0_01]
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[na:1.7.0_01]
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.7.0_01]
    4. java.lang.reflect.Method.invoke(Method.java:601)[na:1.7.0_01]
    4 frames
  3. Spring
    HandlerMethodInvoker.invokeHandlerMethod
    1. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    1 frame
  4. Spring MVC
    FrameworkServlet.doGet
    1. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    2. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    3. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    4. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    5. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    6. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681)[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    7. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)[spring-webmvc-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    7 frames
  5. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:621)[servlet-api.jar:na]
    2. javax.servlet.http.HttpServlet.service(HttpServlet.java:722)[servlet-api.jar:na]
    2 frames
  6. Glassfish Core
    CoyoteAdapter.service
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)[catalina.jar:7.0.22]
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)[catalina.jar:7.0.22]
    3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)[catalina.jar:7.0.22]
    4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)[catalina.jar:7.0.22]
    5. org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)[catalina.jar:7.0.22]
    6. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)[catalina.jar:7.0.22]
    7. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)[catalina.jar:7.0.22]
    8. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)[catalina.jar:7.0.22]
    9. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)[catalina.jar:7.0.22]
    9 frames
  7. org.apache.coyote
    AjpProcessor.process
    1. org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)[tomcat-coyote.jar:7.0.22]
    1 frame
  8. Grizzly HTTP
    JIoEndpoint$SocketProcessor.run
    1. org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)[tomcat-coyote.jar:7.0.22]
    2. org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)[tomcat-coyote.jar:7.0.22]
    2 frames
  9. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)[na:1.7.0_01]
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)[na:1.7.0_01]
    3. java.lang.Thread.run(Thread.java:722)[na:1.7.0_01]
    3 frames