【问题标题】:IllegalStateException on camel cxf route in FUSE (servicemix) ESBFUSE(servicemix)ESB中骆驼cxf路线上的IllegalStateException
【发布时间】:2023-03-22 14:15:01
【问题描述】:

我尝试在 FUSE(版本 4.3.0)ESB/OSGi 容器中设置骆驼(版本 2.4.0)路由。 将 WebService 调用从“代理”地址路由到真实服务应该是一个简单的 cxf-proxy。

我阅读了几个文档:

并设置以下弹簧配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xmlns:osgi="http://www.springframework.org/schema/osgi"
    xmlns:cxf="http://camel.apache.org/schema/cxf"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/osgi
        http://www.springframework.org/schema/osgi/spring-osgi.xsd
        http://camel.apache.org/schema/osgi
        http://camel.apache.org/schema/osgi/camel-osgi.xsd
        http://camel.apache.org/schema/spring
        http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/cxf
        http://camel.apache.org/schema/cxf/camel-cxf.xsd">

    <import
        resource="classpath:META-INF/cxf/cxf.xml" />
    <import
        resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import
        resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
    <import
        resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />

    <!-- the proxy service -->
    <cxf:cxfEndpoint
        id="myServiceProxy"
        address="http://localhost:9003/cxf/myService"
        serviceClass="foo.bar.iface.MyServiceInterface" />

    <!-- my real existing cxf soap service -->
    <cxf:cxfEndpoint
        id="myService"
        address="http://foo.bar/services/myService"
        wsdlURL="http://foo.bar/services/myService?wsdl"
        serviceClass="foo.bar.iface.MyServiceInterface"
        serviceName="s:MyService"
        endpointName="s:MyServiceEndpoint"
        xmlns:s="http://foo.bar/iface/" />

    <!-- route -->
    <camel:camelContext>
        <camel:route>
            <camel:from
                uri="cxf:bean:myServiceProxy" />
            <camel:to
                uri="cxf:bean:myService" />
        </camel:route>
    </camel:camelContext>

</beans>

尝试在 FUSE 中启动捆绑包会导致此异常

karaf@root> Exception in thread "SpringOsgiExtenderThread-22" org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: Endpoint address should be a relative URI wrt to the servlet address (use '/xxx' for example)
        at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1126)
        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
        at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:231)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)

我不知道怎么了。我怀疑我的 Endpoint 地址是错误的,我不知道我的 servlet 地址是什么(没有 cxf:cxfEndoint servelt 地址属性)。

如果能帮助我找到正确的方向来解决这个问题,我们将不胜感激。

谢谢 克劳斯

【问题讨论】:

    标签: apache-camel jbossfuse apache-servicemix fuseesb


    【解决方案1】:

    我终于发现了问题所在。

    相反

    <!-- the proxy service -->
    <cxf:cxfEndpoint
        id="myServiceProxy"
        address="http://localhost:9003/cxf/myService"
        serviceClass="foo.bar.iface.MyServiceInterface" />
    

    应该是的

    <!-- the proxy service -->
    <cxf:cxfEndpoint
        id="myServiceProxy"
        address="/myService"
        serviceClass="foo.bar.iface.MyServiceInterface" />
    

    由于第一种方法在 FUSE 外部运行骆驼项目效果很好(在这种情况下,将启动 http 服务器以提供服务),因此它必须是 FUSE 内部的相对地址。

    在 FUSE 内部,将使用在 (localhost:8181) 上运行的嵌入式 HTTP 服务器,服务 url 将扩展为 http://localhost:8181/cxf/myService

    【讨论】:

      猜你喜欢
      • 2012-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多