7
votes

I am new for Apache Camel concept. I have tried to write sample code using with apache camel API's and I am getting the following exception when try to run the code.

Can anyone help me to solve this issue?

Here's the sample code and an exception as well,

Sample Code :

 CamelContext context = new DefaultCamelContext();
 context.addRoutes(new RouteBuilder() { 
  public void configure() {
    from("direct:start")
    .setHeader(Exchange.HTTP_URI,simple("`http://sample-host:8080/demo/get`"))
    .to("http://emptyhost");
  }
 });
 context.start();
 ProducerTemplate template = context.createProducerTemplate();
 System.out.println(template.requestBodyAndHeaders("direct:start", null, null,String.class));

Exception :

Exception in thread "main" org.apache.camel.FailedToCreateRouteException: 
Failed to create route route1 at: 
    >>> To[`http://sample-host:8080/demo/get`] <<< 
in route: Route(route1)
    [[From[direct:start]] -> [`To[http://sample-host:8`…
because of 
    Failed to resolve endpoint: `http://sample-host:8080/demo/get`
due to: 
    No component found with scheme: http
2
You need to put camel-http library on your classpathKonstantin V. Salikhov
Thanks lot Konstantin V. Salikhov, Now, It's woking fine.Azhaguvel A

2 Answers

4
votes

Dependency libraries were missing. So i have added those libraries and solved my issue.

0
votes

I got the same error, dis is due to use of latest dependencies. so use the older dependencies and try.