org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public void cz.instance.transl.portlet.customers.AjaxUploadFormController.handleMultipartRequest(org.springframework.web.portlet.multipart.DefaultMultipartActionRequest,javax.portlet.ActionResponse) throws com.liferay.portal.kernel.exception.PortalException,com.liferay.portal.kernel.exception.SystemException]; nested exception is java.lang.IllegalStateException: Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c

Spring JIRA | Josef Vychtrle | 5 years ago
  1. 0

    MockActionRequest, MockRenderRequest can be handled by AnnotationMethodHandlerAdapter like this : {code} MockActionRequest request = new MockActionRequest(); Object handler = handlerMapping.getHandler(request).getHandler(); handlerAdapter.handleAction(request, response, handler); {code} But if you do that with MockMultipartActionRequest and your handler method looks like this : {code} @ActionMapping(params = "javax.portlet.action=addFile") public void handleMultipartRequest(DefaultMultipartActionRequest request, ActionResponse response) {code} Then webRequest.getNativeRequest(parameterType) returns null because MockMultipartActionRequest is not assignment-compatible with DefaultMultipartActionRequest {code:title=AnnotationMethodHandlerAdapter.java|borderStyle=solid} protected Object resolveStandardArgument(Class<?> parameterType, NativeWebRequest webRequest) throws Exception { PortletRequest request = webRequest.getNativeRequest(PortletRequest.class); PortletResponse response = webRequest.getNativeResponse(PortletResponse.class); if (PortletRequest.class.isAssignableFrom(parameterType) || MultipartRequest.class.isAssignableFrom(parameterType)) { Object nativeRequest = webRequest.getNativeRequest(parameterType); if (nativeRequest == null) { throw new IllegalStateException( "Current request is not of type [" + parameterType.getName() + "]: " + request) } return nativeRequest; } {code} org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public void cz.instance.transl.portlet.customers.AjaxUploadFormController.handleMultipartRequest(org.springframework.web.portlet.multipart.DefaultMultipartActionRequest,javax.portlet.ActionResponse) throws com.liferay.portal.kernel.exception.PortalException,com.liferay.portal.kernel.exception.SystemException]; nested exception is java.lang.IllegalStateException: Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:181) at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:358) at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:345) at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleAction(AnnotationMethodHandlerAdapter.java:280) at ControllerTest.handleActionRequest(ControllerTest.java:249) Caused by: java.lang.IllegalStateException: Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter$PortletHandlerMethodInvoker.resolveStandardArgument(AnnotationMethodHandlerAdapter.java:611) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveCommonArgument(HandlerMethodInvoker.java:857) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:308) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) ... 37 more

    Spring JIRA | 5 years ago | Josef Vychtrle
    org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public void cz.instance.transl.portlet.customers.AjaxUploadFormController.handleMultipartRequest(org.springframework.web.portlet.multipart.DefaultMultipartActionRequest,javax.portlet.ActionResponse) throws com.liferay.portal.kernel.exception.PortalException,com.liferay.portal.kernel.exception.SystemException]; nested exception is java.lang.IllegalStateException: Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c
  2. 0

    MockActionRequest, MockRenderRequest can be handled by AnnotationMethodHandlerAdapter like this : {code} MockActionRequest request = new MockActionRequest(); Object handler = handlerMapping.getHandler(request).getHandler(); handlerAdapter.handleAction(request, response, handler); {code} But if you do that with MockMultipartActionRequest and your handler method looks like this : {code} @ActionMapping(params = "javax.portlet.action=addFile") public void handleMultipartRequest(DefaultMultipartActionRequest request, ActionResponse response) {code} Then webRequest.getNativeRequest(parameterType) returns null because MockMultipartActionRequest is not assignment-compatible with DefaultMultipartActionRequest {code:title=AnnotationMethodHandlerAdapter.java|borderStyle=solid} protected Object resolveStandardArgument(Class<?> parameterType, NativeWebRequest webRequest) throws Exception { PortletRequest request = webRequest.getNativeRequest(PortletRequest.class); PortletResponse response = webRequest.getNativeResponse(PortletResponse.class); if (PortletRequest.class.isAssignableFrom(parameterType) || MultipartRequest.class.isAssignableFrom(parameterType)) { Object nativeRequest = webRequest.getNativeRequest(parameterType); if (nativeRequest == null) { throw new IllegalStateException( "Current request is not of type [" + parameterType.getName() + "]: " + request) } return nativeRequest; } {code} org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public void cz.instance.transl.portlet.customers.AjaxUploadFormController.handleMultipartRequest(org.springframework.web.portlet.multipart.DefaultMultipartActionRequest,javax.portlet.ActionResponse) throws com.liferay.portal.kernel.exception.PortalException,com.liferay.portal.kernel.exception.SystemException]; nested exception is java.lang.IllegalStateException: Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:181) at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:358) at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:345) at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleAction(AnnotationMethodHandlerAdapter.java:280) at ControllerTest.handleActionRequest(ControllerTest.java:249) Caused by: java.lang.IllegalStateException: Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter$PortletHandlerMethodInvoker.resolveStandardArgument(AnnotationMethodHandlerAdapter.java:611) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveCommonArgument(HandlerMethodInvoker.java:857) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:308) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) ... 37 more

    Spring JIRA | 5 years ago | Josef Vychtrle
    org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public void cz.instance.transl.portlet.customers.AjaxUploadFormController.handleMultipartRequest(org.springframework.web.portlet.multipart.DefaultMultipartActionRequest,javax.portlet.ActionResponse) throws com.liferay.portal.kernel.exception.PortalException,com.liferay.portal.kernel.exception.SystemException]; nested exception is java.lang.IllegalStateException: Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c
  3. 0

    How to config "CommonsMultipartResolver" in spring4 without xml to upload file

    Stack Overflow | 2 years ago | J.K
    java.lang.IllegalStateException: Current request is not of type [org.springframework.web.multipart.MultipartHttpServletRequest]: org.apache.catalina.connector.RequestFacade@5ebfad8d
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring MVC Porlet - java.lang.IllegalStateException: Current request is not of type [javax.portlet.ActionRequest]

    Stack Overflow | 2 years ago | grek
    java.lang.IllegalStateException: Current request is not of type [javax.portlet.ActionRequest]: com.ibm.wps.engine.el.init.AttributeCopyRenderRequestImpl@5a648bc2
  6. 0

    Spring Security & Multipart requests

    Stack Overflow | 4 years ago | Matthew Runo
    java.lang.IllegalStateException: Current request is not of type [org.springframework.web.multipart.MultipartHttpServletRequest]: SecurityContextHolderAwareRequestWrapper[ FirewalledRequest[ org.apache.catalina.connector.RequestFacade@1aee75b7]]

    1 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.IllegalStateException

      Current request is not of type [org.springframework.web.portlet.multipart.DefaultMultipartActionRequest]: org.springframework.mock.web.portlet.MockMultipartActionRequest@b35fb1c

      at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter$PortletHandlerMethodInvoker.resolveStandardArgument()
    2. Spring Web Portlet
      AnnotationMethodHandlerAdapter$PortletHandlerMethodInvoker.resolveStandardArgument
      1. org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter$PortletHandlerMethodInvoker.resolveStandardArgument(AnnotationMethodHandlerAdapter.java:611)
      1 frame
    3. Spring
      HandlerMethodInvoker.invokeHandlerMethod
      1. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveCommonArgument(HandlerMethodInvoker.java:857)
      2. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:308)
      3. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
      4. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:181)
      4 frames
    4. Spring Web Portlet
      AnnotationMethodHandlerAdapter.handleAction
      1. org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:358)
      2. org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:345)
      3. org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleAction(AnnotationMethodHandlerAdapter.java:280)
      3 frames
    5. Unknown
      ControllerTest.handleActionRequest
      1. ControllerTest.handleActionRequest(ControllerTest.java:249)
      1 frame