java - 由于以下原因,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
怎么了?
提前致谢。
解决方案
用于 restlet 生产者的 URI 无效。您指定的 URL 没有正确指定方案。它应该如下所示(注意添加//
after http:
):
<to id="_to1" uri="restlet:http://restcountries.eu:80/rest/v2/alpha/US"/>
推荐阅读
- java - 在动态网页中显示 404
- python - 数组大小如何影响 numpy 矩阵运算执行时间和 CPU 使用率
- android - 我看不到我为每个片段制作的任何布局。我正在使用 Fragments、PagerView 和 TabLayout 制作 SwipeView
- java - 编译时线程“main”java.util.NoSuchElementException 中的异常
- linux - RHEL 中的 openssl - 在不使用 openssl.cnf 的情况下使用 root 签署客户端证书?
- java - 在 Intellij 中导入 Apache poi
- visualforce - 在 Visual force 页面中默认检查 apex:selectOption
- python - 如何按升序对字符串列表(包含数字)进行排序
- twitter-bootstrap - 使用具有不同列数的行时列错位
- javascript - firebase 服务和调试功能?