I have a Spring Boot Application, and use restTemplate to send http request to other services, problem is from time to time(not frequent) I got this Json parse exception. Retry will be successful.
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Connection reset;
nested exception is com.fasterxml.jackson.databind.JsonMappingException: Connection reset (through reference chain: Response["data"]->java.util.ArrayList[23])\n
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:240)\n
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:225)\n
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:96)\n
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:934)\n
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:918)\n
It seems like a simple Json parse error, however I notice that in the call stack there is another cause
Caused by: java.net.SocketException: Connection reset\n
at java.net.SocketInputStream.read(SocketInputStream.java:189)\n
at java.net.SocketInputStream.read(SocketInputStream.java:121)\n
My question will this IO exception cause Json parse error.
My guess is because of TCP issue, part of Json data is lost, then Json cannot be properly parsed by the ObjectMapper.
Related
I’m using Asp.Net Core and Angular 5 and SignalR
I am invoking a hub request from my client that goes to the hub and then to my server which returns a json string back to my hub and then back to the client. For some reason when the JSON string is returned from the hub back to the client (I confirmed that the json string is valid at this point), JsonHubProtocol decides it wants to parse the json string for reasons I can’t even begin to understand and then it throws this error:
vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:12769 ERROR
SyntaxError: Unexpected token t in JSON at position 101966
at JSON.parse (<anonymous>)
at JsonHubProtocol.parseMessages (JsonHubProtocol.js:26)
at HubConnection.processIncomingData (HubConnection.js:233)
at WebSocketTransport.HubConnection.connection.onreceive (HubConnection.js:53)
at WebSocket.webSocket.onmessage (WebSocketTransport.js:84)
at WebSocket.wrapFn [as __zone_symbol___onmessage] (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:108115)
at ZoneDelegate.invokeTask (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:107483)
at Object.onInvokeTask (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:16071)
at ZoneDelegate.invokeTask (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:107482)
at Zone.runTask
I can not for the life of me figure out what is wrong as the json I am returning is valid and being rejected from a SignalR Hub Script that decides it wants to inspect my returned string and when it discovers the string is json it throws an error. It only seems to happen 10% of the time when my server receives a new piece of data and has to re-serialize the Json data and send it to the client side.
I'm getting
java.lang.ArrayIndexOutOfBoundsException: 4000
exception during JsonSerializer with a particular Object value and rest call is resulting in
500Internal Server Error.
below is the exception returned to Dispatcher Servlet after the call is returned back to the client from Rest API call.
org.codehaus.jackson.map.JsonMappingException: 4000 (through reference
chain:
I have tried upgrading the jackson jar version also from 1.9.2 to 1.9.5 and 1.9.13, but still throwing the same exception.
I have tried making all involved POJO objects as serializable also.
If I modify anything in JSON data call is successful with Response 200.
I can't use JSON ignore property also as fields all required.
The same code works fine for other transaction.
Please share some knowledge on it.
I am facing an issue when i am sending a REST request in JSON format.Some of the parameters are getting missed when it invokes the service.However it works fine when i send the request in xml format.The issue which i am geting throws below error:
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "create_session_param"
The object mapper class looks as below:
objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,true);
JaxbAnnotationModule module = new JaxbAnnotationModule();
// maintain JAXB annotation support
objectMapper.registerModule(module);
Can someone please help me to resolve this?
Thanks.
You only have WRAP_ROOT_VALUE which is for serialization. Remember serialization is POJO to JSON. The SerializationFeature.WRAP_ROOT_VALUE is the one that actually adds the "create_session_param" when creating the JSON.
We need JSON to POJO, which is deserialization, which has its own feature set. In this case, we need a feature to unwrap the root value in the JSON. For that there is
DeserializationFeature.UNWRAP_ROOT_VALUE
So do
mapper.configure(DeserializationFeature UNWRAP_ROOT_VALUE, true);
I am using spring framework. From a jsp page I am doing an ajax call which gives call to a controller written using spring framework. From this ajax call a json is passed as controller parameters.
I guess that if the json is small then everything is working fine but if the json length increases then I am getting following exception in the tomcat -
org.springframework.http.converter.HttpMessageNotReadableException:
Could not read JSON: Unexpected end-of-input in VALUE_STRING at
[Source: org.apache.catalina.connector.CoyoteInputStream#147fb5c4;
line: 1, column: 6454794]; nested exception is
org.codehaus.jackson.JsonParseException: Unexpected end-of-input in
VALUE_STRING at [Source:
org.apache.catalina.connector.CoyoteInputStream#147fb5c4; line: 1,
column: 6454794]
Above exception is not coming every time for a big json. In the brower console & also in the network tab I am not getting anything(so not able to capture the json).
can some one please help me out in understanding what may be the cause for this issue & how to resolve this. Its really difficult to debug this scenario as its not always getting reproduced.
I am trying to build a simple POC using wso2ESB. I've created a simple pass through proxy service with an Alfresco service http://www.alfresco.com/
The problem is I am not getting the full JSON data. I've read it has something to do with the axis2-JSON and that it causes problems when one has JSONArray in the root. So I've decided to use message relay.
WSO2 ESB Unable to convert complete JSON data to XML
I've edited the axis2.xml as described in the documentation thus adding the following lines
<messageFormatter contentType="application/json"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
and
<messageBuilder contentType="application/xml"
class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
But after I've restarted the server when I try to use the proxy server through the firefox REST plugin the ESB throws the following exception
[2012-07-12 10:02:29,125] WARN - ClientWorker Unexpected response received. HTTP response co
de : 405 HTTP status : Method Not Allowed exception : SOAP message MUST NOT contain a Documen
t Type Declaration(DTD)
[2012-07-12 10:02:29,125] ERROR - NativeWorkerPool Uncaught exception
java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMTextImpl cannot be cast to org.
apache.axiom.om.OMElement
at org.apache.synapse.util.MessageHelper.cloneSOAPFault(MessageHelper.java:441)
at org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:254)
at org.apache.synapse.core.axis2.SOAPUtils.convertSOAP11toSOAP12(SOAPUtils.java:95)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbac
kReceiver.java:323)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackRecei
ver.java:160)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:275)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.ja
va:173)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
What causes this? Is the problem that ESB still tries to convert the JSON object instead of trying to relay it?
Is there another workaround in parsing these JSON objects (i.e. adding artificial root to the JSON object?)
at the builders you need to set the application/json to use org.wso2.carbon.relay.BinaryRelayBuilder as well.