Spring REST Template java.net.SocketException: Unexpected end of file from server - java

I have a REST Web Service made with Spring MVC 3.2.0 that calls others REST Web Services also with Spring MVC. I'm having the following exception:
25-11-2014 17:49:42-ERROR-ajp-/172.23.111.22:8109-9-pe.com.dummy.BusinessDummyImpl- I/O error on POST request for "http://172.23.111.23/dummy-2/rest/method1":Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://172.23.111.23/dummy-2/rest/method1":Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:499)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:447)
at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:295)
Caused by: java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:747)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:608)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1334)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:479)
at org.springframework.http.client.SimpleClientHttpResponse.getRawStatusCode(SimpleClientHttpResponse.java:47)
at org.springframework.http.client.AbstractClientHttpResponse.getStatusCode(AbstractClientHttpResponse.java:32)
at org.springframework.web.client.DefaultResponseErrorHandler.getHttpStatusCode(DefaultResponseErrorHandler.java:55)
at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:49)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:485)
... 42 more
It happens randomly and when I check the log on dummy-2 WS there is no trace of error.
What can be causing this error?

Related

MultipartException and IOFileUploadException when requests receives MultipartFile

I'm developing a spring API and I have an endpoint that receives a MultipartFile as parameter but in the production environment I'm receiving the following error in some cases:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.impl.IOFileUploadException: Processing of multipart/form-data request failed. java.io.EOFException
I'm using spring-boot-starter-tomcat:2.4.7 that uses tomcat:9.0.46
I'm having some difficulty to debug this error because it throws before the code starts so it never reaches the logs that I put.
Thank you.
Regards.
If this does not happen all the time and only sometimes, its probably because the upload got interrupted ( browser got closed for example ). Therefore, there is nothing for you to change in the code.
You can get more details if you enable Spring MVC debug logging
application.properties
logging.level.org.springframework.web: DEBUG
Here's additional info about how you can efficiently log these kinds of errors.

ResourceAccessException: I/O error on POST request for .. read timed out ERROR

When I call the rest end point (Rest Template http client) "myservice..com/rest/api/" i get the below error sometime .What can be the cause of this error? And is this client or server error?
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "myservice..com/rest/api/": read timed out;
exception is java.net.SocketTimeoutException: read timed out
Well, the exception is declarative in nature. That exception signals that a timeout has occurred on a socket read or accept, as per Java API describes. In shorter words, there is a network connectivity issue that has nothing to do with your code.
A couple of questions that you may want to figure out first:
Is the service myservice..com/rest/api/ up? Is it visible from you computer/host?
Can you hit it an status endpoint to check if it is alive?
Can you make a different HTTP request to the API GET, DELETE?
What happens if you query the endpoint with cURL or Postman?

An error occurred marshalling the object [java.io.IOException: Broken pipe]

I'm getting an error in my Java Springboot application, and the error doesn't mention anywhere which object is failing to be marshalled. We have org.eclipse.persistence.core at v2.7.7.
The full error is:
An I/O error has occurred while writing a response message entity to the container output stream. javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error
at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:994)
....
[Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.7.7.v20200504-69f2c2b80d): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe]
at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:513)
at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:992)
Any ideas on what can cause the broken pipe? Is it due to marshalling an unsupported object? Or maybe there's another underlying issue?

java.security.PrivilegedActionException while hitting webservices over https

I am getting the following exception, when i am trying to hit the webservice over https using java client:
com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0009: Message send failed
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Message send failed
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:157)
at
Also if i use the same code for http , it works fine. Webservices are deployed on weblogic server.
Could anyone help me in resolving the issue.
Regards
Gurleen.
The exception says that message cannot be sent.
Is it a firewall problem like for the same question here : http://www.coderanch.com/t/223309/Web-Services/java/Sending-Soap-requests-thru-Https

javax.servlet.jsp.JspException: Can't insert page ..... Software caused connection abort: socket write error

I just deployed an application to weblogic 10, and when I run my page, I get the custom error page with the following errror in the log.
javax.servlet.jsp.JspException: Can't insert page '/pages/header.jsp' : Software caused connection abort: socket write error
at org.apache.struts.tiles.taglib.InsertTag$InsertHandler.doEndTag(InsertTag.java:899)
at org.apache.struts.tiles.taglib.InsertTag.doEndTag(InsertTag.java:462)
at jsp_servlet._pages._common.__onecolumntemplate._jsp__tag14(__onecolumntemplate.java:761)
at jsp_servlet._pages._common.__onecolumntemplate._jspService(__onecolumntemplate.java:447)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
Any idea what can cause that problem??
Never mind. The exception was coming from another stack above that.

Categories