首页 > 解决方案 > 由于以下原因,Apache Camel Restlet 无法解析端点:null:NullPointerException

问题描述

我是 Apache Camel 的新手。我在独立的 Spring-boot 环境中使用 CodeReady Studio 12.16.0.GA 运行 Red Hat 中间件作为本地 Camel 上下文。我创建了带有 restlet 组件的简单 Fuse 集成项目,以调用 rest 服务。
这是我的骆驼上下文.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>

当我运行我的项目时,我得到了异常:

[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

怎么了?
提前致谢。

标签: javaapache-camelredhatrestlet

解决方案


用于 restlet 生产者的 URI 无效。您指定的 URL 没有正确指定方案。它应该如下所示(注意添加//after http:):

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

推荐阅读