I am using spring MVC 4 with tomcat 8. while uploading file I am receiving following error. I have configured session to expire after an hour.Can anyone guide me in right direction
Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. null] with root cause
java.net.SocketTimeoutException
at org.apache.tomcat.util.net.NioBlockingSelector.read(NioBlockingSelector.java:201)
at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:235)
at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:216)
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1233)
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1182)
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:708)
at org.apache.coyote.http11.Http11InputBuffer.access$300(Http11InputBuffer.java:40)
at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1057)
at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:139) ...
In controller :
@PostMapping(value = "/uploadSurvey")
@ResponseBody
public String uploadSurvey(@Valid FileBucket fileBucket, BindingResult result, HttpSession session) {
if (result.hasErrors())
return "redirect:/surveys/uploadSurvey";
else {
byte[] bytes;
try {
bytes = fileBucket.getFile().getBytes();
String decoded = new String(bytes, "UTF-8");
//Here I do object mapping using jackson
}
catch (Exception e){
e.printStackTrace();
}
}
return "xxx";
}
on client side i am using angularjs to send the file:
fd.append('file', file);
fd.append($scope.csrfParamName, $scope.csrfToken);
$http.post(uploadUrl, fd, {
transformRequest : angular.identity,
headers : {
'Content-Type' : undefined
}
})