Hi, I'm using Camel already, but am now trying to use the HTTP component, and started with the simplest possible usage I can think of - sending a simple search query to Google using a ProducerTemplate. The code runs, but just hangs on the 'template.request(...' call until a timeout of two minutes before throwing a NPE and then the 'DONE!' message:
package com.test; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.ProducerTemplate; import org.apache.camel.impl.DefaultCamelContext; public class OrderProduct { public static void main(String[] args) { CamelContext context = new DefaultCamelContext(); try { ProducerTemplate template = context.createProducerTemplate(); context.start(); Exchange exchange = template.request("http4://www.google.com/search", new Processor() { public void process(Exchange exchange) throws Exception { } }); if (null != exchange) { Message out = exchange.getOut(); int responseCode = out.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class); System.out.println("Response: " + String.valueOf(responseCode)); } Thread.sleep(1000 * 3); context.stop(); } catch (Exception ex) { System.out.println("Exception: " + ex); } System.out.println("DONE!!"); } } *CONSOLE OUTPUT* 11-Jun-2012 20:46:13 org.apache.camel.impl.DefaultCamelContext start INFO: Apache Camel 2.9.2 (CamelContext: camel-1) is starting 11-Jun-2012 20:46:13 org.apache.camel.management.ManagementStrategyFactory create INFO: JMX enabled. Using ManagedManagementStrategy. 11-Jun-2012 20:46:13 org.apache.camel.management.DefaultManagementLifecycleStrategy doStart INFO: StatisticsLevel at All so enabling load performance statistics 11-Jun-2012 20:46:14 org.apache.camel.impl.converter.AnnotationTypeConverterLoader load INFO: Found 3 packages with 15 @Converter classes to load 11-Jun-2012 20:46:14 org.apache.camel.impl.converter.BaseTypeConverterRegistry loadCoreTypeConverters INFO: Loaded 170 core type converters (total 170 type converters) 11-Jun-2012 20:46:14 org.apache.camel.impl.converter.AnnotationTypeConverterLoader load INFO: Loaded 2 @Converter classes 11-Jun-2012 20:46:14 org.apache.camel.impl.converter.BaseTypeConverterRegistry loadTypeConverters INFO: Loaded additional 9 type converters (total 179 type converters) in 0.013 seconds 11-Jun-2012 20:46:14 org.apache.camel.impl.DefaultCamelContext start INFO: Total 0 routes, of which 0 is started. 11-Jun-2012 20:46:14 org.apache.camel.impl.DefaultCamelContext start INFO: Apache Camel 2.9.2 (CamelContext: camel-1) started in 0.292 seconds 11-Jun-2012 20:46:14 org.apache.camel.component.http4.HttpComponent createConnectionManager INFO: Created ClientConnectionManager org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager@18b1aebf 11-Jun-2012 20:46:14 org.apache.camel.component.http4.HttpComponent registerPort INFO: Registering PLAIN scheme http on port 80 11-Jun-2012 20:46:14 org.apache.camel.component.http4.HttpComponent registerPort INFO: Registering PLAIN scheme http4 on port 80 Exception: java.lang.NullPointerException DONE!! -- View this message in context: http://camel.465427.n5.nabble.com/Simplest-Camel-HTTP4-example-not-working-tp5714303.html Sent from the Camel - Users mailing list archive at Nabble.com.