无法解析端点:找不到scheme:servlet的组件

时间:2017-07-31 11:05:17

标签: java apache-camel osgi

我正在尝试在OSGI中注册camel servlet,但在启动时将错误标记为错误

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: servlet://router due to: No component found with scheme: servlet
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:729)
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80)
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:219)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:118)
    at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)
    at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:94)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1278)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:204)

servlet注册,

<bean id="CamelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet" scope="prototype"/>

<osgi:service ref="CamelServlet">
    <osgi:interfaces>
        <value>javax.servlet.Servlet</value>
        <value>org.apache.camel.component.http.CamelServlet</value>
    </osgi:interfaces>
    <osgi:service-properties>
       <entry key="osgi.http.whiteboard.servlet.pattern" value="/camel/*"/>
        <entry key="osgi.http.whiteboard.context.select" value="(osgi.http.whiteboard.context.name=org.osgi.service.http.default)" />            
        <entry key="matchOnUriPrefix" value="true" />
        <entry key="servlet-name" value="CamelServlet"/>
    </osgi:service-properties>
</osgi:service>

和我的骆驼背景如下

<camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="route1">
            <from uri="servlet:router"/>
            <convertBodyTo type="java.lang.String" />
            <transform>
        <simple>${body.toUpperCase()}</simple>
         </transform>
       <!-- and then print to the console -->
        <to uri="stream:out"/>
        </route>
</camelContext>     

使用camel 2.19.1版本,所有必需的包都存在于类路径

1 个答案:

答案 0 :(得分:0)

您需要在运行时安装实现camel组件的功能:

{{1}}