I am trying to use Apache Camel's AHC component for sending a request to multiple URLs at the same time and gather the responses.
To do this on my local machine I have done two things: 1) Created a unit test to test the camel routes configured in my spring context file SendXMLReceiveXMLTest-context.xml. 2) Created a servlet ReceiveXMLSendXMLServlet.java and deployed it on my local Apache Tomcat 6.0.32 server. This servlet does the following: a) Receive an XML b) The XML is unmarshalled into a POJO(VehiclesList.java) using JAXB c) The POJO data is inspected and a new POJO(VehiclesAvailability.java) is created containing the result data. d) The POJO VehiclesAvailability.java is then marshalled back to XML and this XML is sent via response. When I execute the unit test using I encounter a difference, as can be seen below, between the output emitted by test method testSendXMLReceiveXML() and testAsyncHttpRequestsToMultipleURLs(). ==============================mvn install ouput ......... ......... ################# testSendXMLReceiveXML ############## --------------OUTPUT STARTS---------------------- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> Toyota Camry 1615.7 --------------OUTPUT ENDS---------------------- 09-Sep-2011 16:59:46 308 ################# testAsyncHttpRequestsToMultipleURLs : LocalHost ############## --------------OUTPUT STARTS---------------------- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> --------------OUTPUT ENDS---------------------- 09-Sep-2011 16:59:46 394 ################# testAsyncHttpRequestsToMultipleURLs : Google ############## Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.615 sec Running com.poc.apache.camel.message_processing.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec ......... ......... Stack Trace for reference: Some exception occured while unmarshalling javax.xml.bind.UnmarshalException - with linked exception: [java.io.IOException: Invalid CRLF] at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:203) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184) at com.poc.xml.ReceiveXMLSendXMLServlet.getAvailableVehiclesFromVehiclesRequest(ReceiveXMLSendXMLServlet.java:62) at com.poc.xml.ReceiveXMLSendXMLServlet.doGet(ReceiveXMLSendXMLServlet.java:38) at com.poc.xml.ReceiveXMLSendXMLServlet.doPost(ReceiveXMLSendXMLServlet.java:31) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) Caused by: java.io.IOException: Invalid CRLF at org.apache.coyote.http11.filters.ChunkedInputFilter.parseCRLF(ChunkedInputFilter.java:362) at org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:186) at org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:710) at org.apache.coyote.Request.doRead(Request.java:428) at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304) at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:370) at org.apache.catalina.connector.InputBuffer.readByte(InputBuffer.java:317) at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:105) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2932) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:704) at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:200) ... 20 more On inspecting the logs on the server in case of test method /testAsyncHttpRequestsToMultipleURLs()/ the servlet is unable to unmarshal the XML from request input stream and shows the error: *Caused by: java.io.IOException: Invalid CRLF* I am unable to resolve this.Can anybody please help me on why this is happening only in case of test method /testAsyncHttpRequestsToMultipleURLs()/ and the feature works perfectly in case of test method /testSendXMLReceiveXML()/. http://camel.465427.n5.nabble.com/file/n4786393/SourceCode.zip SourceCode.zip P.S.: I have attached the source code for the files mentioned about above in SourceCode.zip. Thanks, Jignesh -- View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-Using-AHC-component-throws-java-io-ioexception-invalid-crlf-tp4786393p4786393.html Sent from the Camel - Users mailing list archive at Nabble.com.