簡體   English   中英

在野蠅上的駱駝cxf

[英]camel cxf on wildfly

我創建了一個SOAP Web服務,並想在wildfly上用camel-cxf公開它。

當我要部署它時,出現以下錯誤:

在ws端點部署中檢測到Apache CXF庫(cxf-core-3.2.0.jar); 提供適當的部署,用容器模塊依賴項替換嵌入式庫,或者為當前部署禁用webservices子系統,並向其添加適當的jboss-deployment-structure.xml描述符。 建議使用前一種方法,因為后一種方法會導致大多數Web服務Java EE和任何JBossWS特定功能被禁用。

嘗試了這里提出的建議但是沒有用。 試圖從我的pom.xml中的caml-cxf include中排除cxf依賴項:

<dependency>
   <groupId>org.apache.camel</groupId>
   <artifactId>camel-cxf</artifactId>
   <version>2.20.0</version>
   <exclusions>
     <exclusion>
         <groupId>org.apache.cxf</groupId>
          <artifactId>*</artifactId>
     </exclusion>
   </exclusions>
</dependency>

那解決了錯誤,但產生了新的錯誤:

Failed to define class org.apache.camel.component.cxf.spring.AbstractCxfBeanDefinitionParser in Module "deployment.CamelCXF-1.0.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/apache/camel/component/cxf/spring/AbstractCxfBeanDefinitionParser

Failed to define class org.apache.camel.component.cxf.spring.CxfEndpointBeanDefinitionParser in Module "deployment.CamelCXF-1.0.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser

Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/camel.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.camel.component.cxf.spring.NamespaceHandler] for namespace [http://camel.apache.org/schema/cxf]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: Failed to link org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser

您能否幫助我解決這些錯誤,或者提供一個可以在wildfly上進行部署和擴展的小型示例? 非常感激。

在我的pom.xml中定義了這些依賴項:

<dependencies>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-cxf</artifactId>
        <version>2.20.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>5.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>8.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

這是我的camel.xml:

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

<cxf:cxfEndpoint id="customerEndpoint"
                 address="http://localhost:8080/TestService/"
                 serviceClass="my.package.TestService"
                 wsdlURL="WEB-INF/CustomerService.wsdl"/>

<bean id="logBean" class="my.package.LogBean"/>

<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="cxf:bean:customerEndpoint" /> 
        <to uri="bean:logBean" />
    </route>
</camel:camelContext>

后續問題

我可以使用@Tadayoshi Sato提供的鏈接來設置Web服務。 但是,這些示例僅將一個簡單功能與一個處理器一起使用。 在端口定義中有多個操作時,如何知道調用了哪個函數? 是否可以讓駱駝調用所提供的接口的實現,或者我必須自己映射它?

正如克勞斯指出的,在WildFly上使用駱駝的最推薦方法是使用WildFly Camel。 您可以在下面的鏈接中找到如何將WildFly Camel子系統安裝到WildFly:
http://wildfly-extras.github.io/wildfly-camel/index.html

安裝WildFly Camel之后,讓我們看一下此鏈接,您可以在其中找到如何在WildFly上使用camel-cxf開發代碼:
http://wildfly-extras.github.io/wildfly-camel/index.html#_jax_ws

關鍵是WildFly已經擁有自己的CXF庫作為子系統,並且您需要盡可能多地使用內置庫。 否則,您可能會遇到類似問題的尷尬問題。 它是WildFly Camel子系統,可讓您將基礎WildFly子系統用於您的Camel應用程序。

更新:

對於camel-cxf使用者,可以通過CxfConstants.OPERATION_NAME消息頭獲得被調用的操作名稱。 根據:
https://github.com/apache/camel/blob/master/components/camel-cxf/src/main/docs/cxf-component.adoc

camel-cxf端點使用者POJO數據格式基於CXF調用程序 ,因此消息頭具有名稱為CxfConstants.OPERATION_NAME的屬性,消息主體是SEI方法參數的列表。

您可以基於此消息頭路由消息,並相應地更改實現。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM