Project: talendesb
Issue TESB-7276: Throw exception in component tRESTClient POST method when RestService response a null body
In studio Talend-Studio-r91999-V5.2.0NB, model is using "tRESTClient" component, in order to test the http POST method. Select the Accept Type is "XML", then start the rest service which only response the http status code and the body is null ( btw, if response body is not null, then it worked well). Then run this rest client POST job, throw the below exception, {noformat} Exception in component tRESTClient_1 javax.ws.rs.client.ClientException: java.lang.NoClassDefFoundError: org/codehaus/jettison/JSONSequenceTooLargeException org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:981) org.apache.cxf.jaxrs.client.WebClient.doResponse(WebClient.java:944) org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:894) org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:761) org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:748) org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:355) org.apache.cxf.jaxrs.client.WebClient.post(WebClient.java:381) mfshen20121012.test_restclient_post_0_1.Test_RESTClient_Post.tFixedFlowInput_1Process(Test_RESTClient_Post.java:1419) mfshen20121012.test_restclient_post_0_1.Test_RESTClient_Post.runJobInTOS(Test_RESTClient_Post.java:1804) mfshen20121012.test_restclient_post_0_1.Test_RESTClient_Post.main(Test_RESTClient_Post.java:1669) Caused by: java.lang.NoClassDefFoundError: org/codehaus/jettison/JSONSequenceTooLargeException org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:241) org.apache.cxf.jaxrs.provider.dom4j.DOM4JProvider.readFrom(DOM4JProvider.java:67) org.apache.cxf.jaxrs.provider.dom4j.DOM4JProvider.readFrom(DOM4JProvider.java:38) org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1141) org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:470) org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:960)	... 9 more Caused by: java.lang.ClassNotFoundException: org.codehaus.jettison.JSONSequenceTooLargeException java.net.URLClassLoader$1.run(URLClassLoader.java:202) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:190) java.lang.ClassLoader.loadClass(ClassLoader.java:306) sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) java.lang.ClassLoader.loadClass(ClassLoader.java:247)	... 15 more {noformat} BTW, PUT method worked well in the same way, and if select Accept Type "any" for POST method, then POST rest client job also can work well. With Liugang's help, after resolve the exception NoClassDefFoundError, then throw another exception. {noformat} 2012-10-12 17:08:08 org.apache.cxf.jaxrs.provider.AbstractJAXBProvider handleExceptionStart 警告: javax.xml.stream.XMLStreamException: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 0 of org.codehaus.jettison.mapped.MappedXMLInputFactory.createXMLStreamReader(MappedXMLInputFactory.java:46) org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:116) org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:103) org.apache.cxf.jaxrs.provider.json.utils.JSONUtils.createStreamReader(JSONUtils.java:151) org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:267) org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:257) org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:209) org.apache.cxf.jaxrs.provider.dom4j.DOM4JProvider.readFrom(DOM4JProvider.java:67) org.apache.cxf.jaxrs.provider.dom4j.DOM4JProvider.readFrom(DOM4JProvider.java:38) org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1141) org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:470) org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:960) org.apache.cxf.jaxrs.client.WebClient.doResponse(WebClient.java:944) org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:894) org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:761) org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:748) org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:355) org.apache.cxf.jaxrs.client.WebClient.post(WebClient.java:381) mfshen20121012_02.test_restclient_post02_0_1.Test_RESTClient_POST02.tFixedFlowInput_1Process(Test_RESTClient_POST02.java:1422) mfshen20121012_02.test_restclient_post02_0_1.Test_RESTClient_POST02.runJobInTOS(Test_RESTClient_POST02.java:1856) mfshen20121012_02.test_restclient_post02_0_1.Test_RESTClient_POST02.main(Test_RESTClient_POST02.java:1721) Caused by: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 0 of org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:463) org.codehaus.jettison.json.JSONObject.(JSONObject.java:173) org.codehaus.jettison.mapped.MappedXMLInputFactory.createJSONObject(MappedXMLInputFactory.java:51) org.codehaus.jettison.mapped.MappedXMLInputFactory.createXMLStreamReader(MappedXMLInputFactory.java:43)	... 20 more 2012-10-12 17:08:08 org.apache.cxf.jaxrs.client.AbstractClient reportMessageHandlerProblem 严重: .Problem with reading the response message, class : interface org.dom4j.Document, ContentType : */*. Exception in component tRESTClient_1 javax.ws.rs.client.ClientException: .Problem with reading the response message, class : interface org.dom4j.Document, ContentType : */*. org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:662) org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:474) org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:960) org.apache.cxf.jaxrs.client.WebClient.doResponse(WebClient.java:944) org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:894) org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:761) org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:748) org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:355) org.apache.cxf.jaxrs.client.WebClient.post(WebClient.java:381) mfshen20121012_02.test_restclient_post02_0_1.Test_RESTClient_POST02.tFixedFlowInput_1Process(Test_RESTClient_POST02.java:1422) mfshen20121012_02.test_restclient_post02_0_1.Test_RESTClient_POST02.runJobInTOS(Test_RESTClient_POST02.java:1856) mfshen20121012_02.test_restclient_post02_0_1.Test_RESTClient_POST02.main(Test_RESTClient_POST02.java:1721) Caused by: javax.ws.rs.WebApplicationException: javax.xml.stream.XMLStreamException: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 0 of org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.handleExceptionEnd(AbstractJAXBProvider.java:625) org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.handleXMLStreamException(AbstractJAXBProvider.java:642) org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:244) org.apache.cxf.jaxrs.provider.dom4j.DOM4JProvider.readFrom(DOM4JProvider.java:67) org.apache.cxf.jaxrs.provider.dom4j.DOM4JProvider.readFrom(DOM4JProvider.java:38) org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1141) org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:470)	... 10 more Caused by: javax.xml.stream.XMLStreamException: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 0 of org.codehaus.jettison.mapped.MappedXMLInputFactory.createXMLStreamReader(MappedXMLInputFactory.java:46) org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:116) org.codehaus.jettison.AbstractXMLInputFactory.createXMLStreamReader(AbstractXMLInputFactory.java:103) org.apache.cxf.jaxrs.provider.json.utils.JSONUtils.createStreamReader(JSONUtils.java:151) org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:267) org.apache.cxf.jaxrs.provider.json.JSONProvider.createReader(JSONProvider.java:257) org.apache.cxf.jaxrs.provider.json.JSONProvider.readFrom(JSONProvider.java:209)	... 14 more Caused by: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 0 of org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:463) org.codehaus.jettison.json.JSONObject.(JSONObject.java:173) org.codehaus.jettison.mapped.MappedXMLInputFactory.createJSONObject(MappedXMLInputFactory.java:51) org.codehaus.jettison.mapped.MappedXMLInputFactory.createXMLStreamReader(MappedXMLInputFactory.java:43)	... 20 more {noformat}
Story points: 1