How to solve "Failed to create route1 route exception" in Apache Camel?

I am new to Apache Camel concept. I tried to write sample code using the Apache Camel API and I get the following exception when I try to run the code.

Can someone help me solve this problem?

Here is also an example code and an exception,

Code example:

 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));

An 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
+4
source share
1 answer

No dependency libraries. So I added these libraries and solved the problem.

+3
source

Source: https://habr.com/ru/post/1527111/


All Articles