在 EAP 上部署 Fuse Camel 项目

Deploy Fuse Camel Project on EAP

我使用 SOAP Web 服务构建了一个简单的 Camel 项目,该项目写入一个文件并发送响应:它被打包为包并且我成功地将它部署在 Karaf 上,您可以在此处找到源代码

Firefox Send

然后我想将此项目转换为 WAR 模块并将其部署在 EAP 上的 Fuse 上:按照这些说明进行操作

Apache Camel: Tutorial on using Camel in a Web Application

我修改了(在 pom.xml 中)bundle -> war,我将 applicationContext.xml 移到 src/main/webapp 下,并创建了一个 web.xml Spring 上下文加载器:当我安装 WAR 时,我看到(在服务器日志上)Camel 路由已启动但未公开 SOAP WS

10:03:40,981 INFO  [org.apache.camel.spring.SpringCamelContext] (ServerService Thread Pool -- 75) Apache Camel 2.15.1 (CamelContext: camelId) is starting

10:03:40,994 INFO  [org.apache.camel.management.ManagedManagementStrategy] (ServerService Thread Pool -- 75) JMX is enabled

10:03:41,120 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (ServerService Thread Pool -- 75) Loaded 197 type converters

10:03:41,339 INFO  [org.apache.camel.spring.SpringCamelContext] (ServerService Thread Pool -- 75) AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.

10:03:41,339 INFO  [org.apache.camel.spring.SpringCamelContext] (ServerService Thread Pool -- 75) StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html

10:03:41,370 INFO  [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (ServerService Thread Pool -- 75) Creating Service {http://www.springframework.org/schema/beans}CamelHelloWorldService from WSDL: classpath:wsdl/Hello.wsdl

10:03:41,732 INFO  [org.apache.cxf.endpoint.ServerImpl] (ServerService Thread Pool -- 75) Setting the server's publish address to be /CamelHelloWorld

10:03:41,764 INFO  [org.apache.camel.spring.SpringCamelContext] (ServerService Thread Pool -- 75) Route: route2 started and consuming from: Endpoint[cxf://bean:helloWorldEndpointId]

10:03:41,764 INFO  [org.apache.camel.spring.SpringCamelContext] (ServerService Thread Pool -- 75) Total 1 routes, of which 1 is started.

10:03:41,764 INFO  [org.apache.camel.spring.SpringCamelContext] (ServerService Thread Pool -- 75) Apache Camel 2.15.1 (CamelContext: camelId) started in 0.783 seconds

10:03:41,764 INFO  [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 75) Root WebApplicationContext: initialization completed in 2131 ms

10:03:41,826 INFO  [org.jboss.as.server] (HttpManagementService-threads - 2) JBAS015859: Deployed "camel-hello-world-0.0.21-SNAPSHOT.war" (runtime-name : "camel-hello-world-0.0.21-SNAPSHOT.war")

老实说我也看到了这个异常

10:03:39,711 WARN  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 75) Ignored XML validation warning: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 419; SchemaLocation: schemaLocation value = ' http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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 http://camel.apache.org/schema/cxf/camel-cxf-spring.xsd' must have even number of URI's.

at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)

at org.apache.xerces.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:97)

at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)

at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)

但我认为这只是一个war宁。

有人知道吗?

提前致谢

“必须有偶数个 URI”异常是因为您在 xsi:schemaLocation.

末尾有一个多余的 camel-cxf-spring.xsd 条目

您可能会发现将代码基于 Camel Tomcat CXF example 会更好,因为它演示了如何在 web.xml 中设置 CXFServlet。如果您希望 CXF 消费者工作,您将需要它。例如:

<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/webservices/*</url-pattern>
</servlet-mapping>

如果您在 EAP 7.0 或 7.1 上使用 Fuse,您可以避免 Spring ContextLoaderListenerCXFServlet,因为应用服务器负责引导 Spring & CXF 为您服务。有一个示例项目 here.