javaapache-camelredhatrestlet

Apache Camel Restlet failed to resolve endpoint due to: null: NullPointerException


I am newbee in Apache Camel. I run Red Hat middleware with CodeReady Studio 12.16.0.GA on standalone Spring-boot environment as local Camel context. I have created simple Fuse integration project with restlet component to make callout to rest service.
Here is my camel-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="        http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd        http://camel.apache.org/schema/spring       https://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <route id="simple-route">
        <from id="route-timer" uri="timer://foo"/>
        <to id="_to1" uri="restlet:http:restcountries.eu:80/rest/v2/alpha/US"/>
        <setBody id="_setBody1">
            <simple>${body}</simple>
        </setBody>
        <log id="route-log" message=">>> ${body}"/>
    </route>
</camelContext>
</beans>

When I run my project I get exception:

[ERROR] Failed to execute goal org.jboss.redhat-fuse:spring-boot-maven-plugin:7.6.0.fuse-760027-redhat-00001:run (default-cli) on project camel-ose-springboot-xml: An exception occurred while running. null: InvocationTargetException: org.apache.camel.FailedToCreateRouteException: Failed to create route simple-route at: >>> To[restlet:http:restcountries.eu:80/rest/v2/alpha/US] <<< in route: Route(simple-route)[[From[timer://foo]] -> [To[restlet:http:... because of Failed to resolve endpoint: restlet://http:restcountries.eu:80//rest/v2/alpha/US due to: null: NullPointerException

What is wrong?
Thanks in advance.


Solution

  • The URI used for the restlet producer is not valid. The URL you have specified does not have the scheme specified correctly. It should look like the following (note the addition of // after http:):

    <to id="_to1" uri="restlet:http://restcountries.eu:80/rest/v2/alpha/US"/>