I've been struggling to solve this issue here, and i can't find what i am doing wrong.
I am trying to make a simple JSON Post, using Spring RestTemplate, and sending all information as String to be simple all the way around as follows:
RestTemplate restTemplate = new RestTemplate();
JSONObject issue = getJSONIssue(redmine);
try {
String response = restTemplate.postForObject(redmineProperties.getUrl()+"/issues.json?key="+redmineProperties.getKey(), issue.toJSONString(), String.class);
}catch(RestClientException e){
e.printStackTrace();
}
My JSONObject looks like:
{"issue":
{"priority_id":4,
"description":"asdasdasdasd",
"subject":"adasdad",
"project_id":4
}
}
This is the data i am trying to sendo via Post, and the server keep sending me the error:
[http-bio-8080-exec-7] WARN org.springframework.web.client.RestTemplate - POST request for "http://xxx.com.br/issues.json?key=b8143da980578fee4db0b33bd3cd3eec511797d6" resulted in 422 (Unprocessable Entity); invoking error handler
org.springframework.web.client.HttpClientErrorException: 422 Unprocessable Entity
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:589)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:547)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:503)
at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:331)
at br.com.cubbes.docmidia.controller.redmine.RedmineController.saveUser(RedmineController.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
when i send the same data via a client like insomnia by Google Chrome, the servers resolves without a problem.
Do anyone know what i could be doing wrong here?
For anyone coming here for 422 Unprocessable Entity, as suggested in one of the comments, setting the content-type:application/json fixed the error for me.
RequestEntity<ValidationRequest> requestEntity = RequestEntity.post(validatorUri)
.contentType(MediaType.APPLICATION_JSON)
.body(validationRequest);
JsonNode validationResponse = restTemplate.exchange(requestEntity, JsonNode.class).getBody();
I ended up using a specific library to manipulate this REST calls:
http://www.redmine.org/projects/redmine/wiki/Rest_api_with_java
Thanks guys
Related
I am new in Rest API's. I am trying to run this test function in IntelliJ IDEA to test OMDB API:
#Test
public void shouldNotGetResponseWithoutApiKey(){
Response response = RestAssured.given()
.queryParam("t", "Harry Potter")
.get("http://www.omdbapi.com")
.then()
.statusCode(401)
.extract().response();
assertThat(response.getBody().jsonPath().getString("Error"), Matchers.containsString(errorMessage));
}
Here the logic is: I want this test to give status code 401 since the API Key is not given to the Rest Assured. It's very straight forward. But I receive this error:
io.restassured.internal.http.HttpResponseException: Unauthorized
at io.restassured.internal.http.HTTPBuilder.defaultFailureHandler(HTTPBuilder.java:627)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1268)
...
I searched for the error but I couldn't find a solution. I would be very happy if someone can direct me.
Thanks a lot 🙌
I believe I have followed the guidelines correctly from this website https://vandeneyndefilip.nu/spring-boot/spring-boot-sending-email/, but I get an exception reading response.
I tried to find a solution to the problem on the internet and all I could get was to change the port from 465 to 587. unfortunately, I did use port 587 from the start
this is my application.properties
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=myemail#gmail.com
spring.mail.password=mypassword
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
this is my implementation
String jsonData = user.toJson();
System.out.println(jsonData);
byte[] arrayBlob = blobTemplate.getBytes(1, (int) blobTemplate.length());
String data = new String(arrayBlob);
String newData = MustacheProcessor.mustacheProcess(data, jsonData);
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(user.getEmail());
message.setSubject(template.getSubject());
message.setText(newData);
emailSender.send(message);
} catch (MailException e) {
e.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
I tried to see the data transfer on this line, and everything was fine
message.setTo(user.getEmail());
message.setSubject(template.getSubject());
message.setText(newData);
I have read the trace and there seems to be a problem when sending email
emailSender.send(message);
this is a half of the trace
nested exception is:
java.net.SocketException: Connection reset. Failed messages: javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset; message exception details (1) are:
Failed message 1:
javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2460)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2187)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
at javax.mail.Service.connect(Service.java:366)
at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:517)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:436)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:322)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:311)
at com.sender.tugaskp2.tugaskp2.service.impl.EmailServiceImp.sendSinglePayslip(EmailServiceImp.java:55)
at com.sender.tugaskp2.tugaskp2.controller.EmailController.sendSinglePayslip(EmailController.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
I have solved this problem by replacing the network that I use and activating less secure app access for my email. I'm not sure this is the most appropriate answer to this problem.
I got the answer from this link
https://www.mkyong.com/spring-boot/spring-boot-how-to-send-email-via-smtp/
have a nice day
I have a scenario where I want to pause a pineline using my spring-boot service. I am using Spring-boot and Go Pipeline API 16.1.0
Following is actual url available in GO API documentation to pause pipeline through CURL which is working perfectly
curl 'http://ci.example.com/go/api/pipelines/dev1-pineline/pause' -u
'username:password' -X POST -d 'pauseCause=testing Pause'
Above CURL URL working as expected but when I try to do same with RestTemplate it's not working.
RestTemplate function code is
public Object pausePipeline() {
String credentials = userName+":"+password;
byte[] encoding = Base64.encodeBase64(credentials.getBytes());
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", String.valueOf(encoding));
//headers.setContentType(MediaType.APPLICATION_JSON); // optional
String url = String.format("%s/%s%s", pipelineUrl,pipelineName,"/pause");
String data = "pauseCause=Monthend process started.";
HttpEntity<String> entity = new HttpEntity<>(data, headers);
return restTemplate.exchange(url, HttpMethod.POST, entity , Object.class).getBody();
}
Above code throws an exception when try to connect using Rest endpoint Exception stacktrace is
[o.a.c.c.C.[.[.[.[dispatcherServlet]] (http-nio-8080-exec-1) Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.HttpClientErrorException: 401 Full authentication is required to access this resource] with root cause
org.springframework.web.client.HttpClientErrorException: 401 Full authentication is required to access this resource
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:614) ~[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:570) ~[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530) ~[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:448) ~[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at com.premierinc.forecasting.suggesteds.MonthEndService.pausePipeline(MonthEndService.java:51) ~[main/:?]
at com.premierinc.forecasting.web.ExtractsApi.pauseMonendPipeline(ExtractsApi.java:104) ~[main/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270) ~[springloaded-1.2.3.RELEASE.jar:1.2.3.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[seb-4.1.6.RELEASE.jar:4.1.6.RELEASE]
You might want to prepend Basic to your Authorization header. The relevant change in your code might be similar to the one below
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Basic " + String.valueOf(encoding));
Reference - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization#Examples
I'm using Spring framework, but not too familiar with it. I'm writing a REST API, specifically a POST method that handles a file upload where the file is optional.
I've tried to simplify the method down but still having a problem. Here is what I have
#RequestMapping(method = RequestMethod.POST, value="/items")
public String create(#RequestParam(value="file", required=false) MultipartFile file) {
return "Create";
}
The method works fine when I include a file in my form request, however when I don't have a file (as I want it to be optional). I have tried replacing the #RequestParam with a HttpServletRequest parameter yielding the same results.
I get a 500 error with the following stack trace:
java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: Stream ended unexpectedly
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
</pre></p><p><b>root cause</b> <pre>org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: Stream ended unexpectedly
org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:99)
org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:77)
org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:76)
org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1067)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:906)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
</pre></p><p><b>root cause</b> <pre>java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: Stream ended unexpectedly
org.apache.catalina.connector.Request.parseParts(Request.java:2806)
org.apache.catalina.connector.Request.parseParameters(Request.java:3096)
org.apache.catalina.connector.Request.getParameter(Request.java:1145)
org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:382)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
</pre></p><p><b>root cause</b> <pre>org.apache.tomcat.util.http.fileupload.FileUploadException: Stream ended unexpectedly
org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:311)
org.apache.catalina.connector.Request.parseParts(Request.java:2737)
org.apache.catalina.connector.Request.parseParameters(Request.java:3096)
org.apache.catalina.connector.Request.getParameter(Request.java:1145)
org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:382)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
</pre></p><p><b>root cause</b> <pre>org.apache.tomcat.util.http.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
org.apache.tomcat.util.http.fileupload.MultipartStream.readHeaders(MultipartStream.java:480)
org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:889)
org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:854)
org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:259)
org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:283)
org.apache.catalina.connector.Request.parseParts(Request.java:2737)
org.apache.catalina.connector.Request.parseParameters(Request.java:3096)
org.apache.catalina.connector.Request.getParameter(Request.java:1145)
org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:382)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
I found only one post in my search on the web and it talks about this potentially being a bug in Spring. I've been stuck on this problem for a while now and would great appreciate some help.
Thanks
Here is the solution I ended up with.
#RequestMapping(method = RequestMethod.POST, value = "/object")
ResponseEntity<Object> create(#RequestParam("is_file") boolean isFile, HttpServletRequest request) {
if(isFile) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("file");
} else{
// You can add other parameters (as long as it isn't a multipart parameter) and do other stuff here
}
}
I can see question is a bit old, but I put my answer here because uploading files topic is always alive.
I tested Spring Boot 1.3.5.RELEASE in context of this question.
I defined rest service as below and it works when file is not attached to multipart/form-data.
I tested service with RestTemplate client.
#RequestMapping(method = RequestMethod.POST)
public ResponseEntity<String> upload(#RequestPart(value = "name", required = false) String name,
#RequestPart(value = "file", required = false) MultipartFile file)
I had the same issue and just adding the required=false worked for me. Please find the sample code below,
#RequestMapping(method = RequestMethod.POST, value="/items")
public String create(#RequestParam(value ="file", required=false) MultipartFile file) {
return "Create";
}
I have a post method in my Spring controller that takes one request parameter called wkt. Here is my method signature:
#RequestMapping(value="/getNumberOfProperties", method=RequestMethod.POST)
public String getEstimateForNumberOfProperties(#RequestParam("wkt") String wkt) {
//code
}
In my jQuery, I am calling this method like this.
$.post(webroot + "/project/getNumberOfProperties", {wkt : wktGeomFromServer})
This works great. However, I was getting this error for wkt strings that are too long.
org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'wkt' is not present
at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:255) ~[spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:95) ~[spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:79) ~[spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:157) ~[spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:124) ~[spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) ~[spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690) ~[spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) ~[spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) [spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) [spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) [spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863) [spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) [servlet-api.jar:?]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) [spring-webmvc-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) [servlet-api.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.41]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.41]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
So how long is too long? After doing some testing, I have discovered that if the length of the string is 1,971,324 or less everything works. Otherwise, I get the above exception. I don't know if this is something with Spring, or tomcat, etc. Also, I have verified with Chrome that wkt parameter is getting sent in all cases, regardless of length. So the Spring error message when it is too long does not make much sense to me. Is 1,971,324 some magic number somewhere?
Any suggestions?
Could it be server configuration issue? For example Tomcat has 2MB maximum post request content size by default.