I am using Spring 3.1.1. I have a file upload feature and have implemented HandlerExceptionResolver to handle file size limit. I have configured the size in spring mvc xml with "maxUploadSize" attribute. My application uses spring security with open id.
I am using the code below in resolveException() of that upload controller. RestResponse is a pojo with error message and status
ModelAndView mav = new ModelAndView();
RestResponse fail_response = new RestResponse();
fail_response.setMessage("Max upload limit failure.");
I can see from the logs that, the resolveException() is invoked, however the json response is not shown in the rest api client/browser. I can see the exception in the log (Maximum upload size of 10485760 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (30611515) exceeds the configured maximum (10485760)) immediately after the upload, but the upload still continues and after a while the json error message (available above) is shown in the browser.
I did check for this problem in stackoverflow and other portals and could not find why it is not shown or response is returned to the UI.
See this issue and this SO. If still not clear, refer to this link
and search for maxFileSize and maxRequestSize. Add same settings in your application.yml