我是Apache Camel的newbee。
我在独立的Spring-boot环境中使用CodeReady Studio 12.16.0.GA作为本地Camel上下文运行Red Hat中间件。
我已经创建了一个带有restlet组件的简单Fuse集成项目,以便对其余服务进行标注。
这是我的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>
运行项目时出现异常:
[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
怎么了?
预先感谢。
答案 0 :(得分:1)
用于restlet生产者的URI无效。您指定的网址没有正确指定方案。看起来应如下所示(注意在//
之后添加http:
)
<to id="_to1" uri="restlet:http://restcountries.eu:80/rest/v2/alpha/US"/>
答案 1 :(得分:0)
您需要在pom文件中添加骆驼restlet依赖项。
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<version>YOUR CAMEL VERSION</version>
</dependency>
或者因为您正在使用保险丝,所以您可能需要安装骆驼式马桶功能:
feature:install camel-restlet