vendredi 30 juin 2017

Spring mockMvc throws error when using ExceptionHandler

I am using SpringMockMvc and in my controller I have @ExceptionHandler. When calling post request, I am getting the below error.

Failed to invoke @ExceptionHandler method: public org.springframework.http.ResponseEntity<com.xx.xxx> com.xx.xx.handleException(java.lang.Throwable,org.eclipse.jetty.server.Request)
java.lang.IllegalStateException: Current request is not of type [org.eclipse.jetty.server.Request]: org.springframework.mock.web.MockHttpServletRequest@47fac1bd
        at org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver.resolveArgument(ServletRequestMethodArgumentResolver.java:97)

I am not sure why @ExceptionHandler cannot handle if the request is of type org.springframework.mock.web.MockHttpServletRequest

Aucun commentaire:

Enregistrer un commentaire