我在pom.xml依赖项下的JBoss EAP 6.4上的JBoss Fuse 6.3上构建了Camel WAR,并公开了WS SOAP
<packaging>war</packaging>
<properties>
<cxf-version>3.1.5.redhat-630187</cxf-version>
<camel.version>2.17.0.redhat-630187</camel.version>
<spring.version>3.2.16.RELEASE</spring.version>
</properties>
<parent>
<groupId>org.jboss.fuse.bom</groupId>
<artifactId>jboss-fuse-parent</artifactId>
<version>6.3.0.redhat-371</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.fuse.bom</groupId>
<artifactId>jboss-fuse-parent</artifactId>
<version>6.3.0.redhat-371</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-parent</artifactId>
<scope>provided</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core-osgi</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cdi</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-servlet</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http4</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
<version>${camel.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.3</version>
</dependency>
<!-- JSON Provider per CXF-RS -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
</dependencies>
和带有骆驼上下文的spring xml文件(applicationContext.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:cxf="http://camel.apache.org/schema/cxf"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" 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">
<!-- Producer -->
<cxf:cxfEndpoint address="/MyService_v1.0"
id="myservice-endpointId" serviceClass="it.mypackage.MyServicePortImpl"/>
<camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
<camel:route id="myservice-route">
<camel:from id="_myservice-routefrom2" uri="cxf:bean:myservice-endpointId"/>
<to id="_myservice-routeto2" uri="provaProcessorId2"/>
</camel:route>
</camelContext>
<bean class="it.mypackage.ProvaProcessor" id="provaProcessorId2"/>
</beans>
为了使applicationContext.xml在META-INF / spring下(而不是在web.xml的同一级别上),我如下修改了web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:META-INF/spring/*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>
<display-name>Camel Http Transport Servlet</display-name>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/webservices/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
这可以工作,但是我需要将spring xml文件命名为applicationContext.xml,而不是applicationContext.xml:如果我在something-camel-context.xml中重命名applicationContext.xml,则会在WAR启动过程中得到例外
22:42:50,223 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015960: Class Path entry jaxb-api.jar in /C:/JBoss/EAP/jboss-eap-6.4/bin/content/myapplication-0.0.1-SNAPSHOT.war/WEB-INF/lib/jaxb-core-2.2.11.jar does not point to a valid jar for a Class-Path reference.
22:42:50,225 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015960: Class Path entry jaxb-core.jar in /C:/JBoss/EAP/jboss-eap-6.4/bin/content/myapplication-0.0.1-SNAPSHOT.war/WEB-INF/lib/jaxb-impl-2.2.11.redhat-2.jar does not point to a valid jar for a Class-Path reference.
22:42:50,278 INFO [org.wildfly.extension.camel] (MSC service thread 1-8) Camel context descriptors found
22:42:50,278 INFO [org.wildfly.extension.camel] (MSC service thread 1-8) Camel context descriptors found
22:42:51,387 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016002: Processing weld deployment myapplication-0.0.1-SNAPSHOT.war
22:42:51,407 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."myapplication-0.0.1-SNAPSHOT.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myapplication-0.0.1-SNAPSHOT.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "myapplication-0.0.1-SNAPSHOT.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_144]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_144]
Caused by: java.lang.NoClassDefFoundError: org/apache/camel/core/osgi/utils/BundleContextUtils
at org.apache.camel.cdi.CdiCamelEnvironment.hasBundleContext(CdiCamelEnvironment.java:56)
at org.apache.camel.cdi.CdiCamelEnvironment.<init>(CdiCamelEnvironment.java:33)
at org.apache.camel.cdi.CdiCamelExtension.<init>(CdiCamelExtension.java:85)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_144]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_144]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_144]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [rt.jar:1.8.0_144]
at java.lang.Class.newInstance(Class.java:442) [rt.jar:1.8.0_144]
at org.jboss.as.weld.deployment.WeldPortableExtensions.tryRegisterExtension(WeldPortableExtensions.java:54)
at org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadAttachments(WeldPortableExtensionProcessor.java:119)
at org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.deploy(WeldPortableExtensionProcessor.java:79)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
... 5 more
Caused by: java.lang.ClassNotFoundException: org.apache.camel.core.osgi.utils.BundleContextUtils from [Module "org.apache.camel.component.cdi:main" from local module loader @9e89d68 (finder: local module finder @3b192d32 (roots: C:\JBoss\EAP\jboss-eap-6.4\modules,C:\JBoss\EAP\jboss-eap-6.4\modules\system\layers\fuse,C:\JBoss\EAP\jboss-eap-6.4\modules\system\layers\soa,C:\JBoss\EAP\jboss-eap-6.4\modules\system\layers\base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.6.Final-redhat-1]
... 17 more
22:42:51,417 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 4) JBAS014612: Operation ("add") failed - address: ([("deployment" => "myapplication-0.0.1-SNAPSHOT.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"myapplication-0.0.1-SNAPSHOT.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"myapplication-0.0.1-SNAPSHOT.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"myapplication-0.0.1-SNAPSHOT.war\"
Caused by: java.lang.NoClassDefFoundError: org/apache/camel/core/osgi/utils/BundleContextUtils
Caused by: java.lang.ClassNotFoundException: org.apache.camel.core.osgi.utils.BundleContextUtils from [Module \"org.apache.camel.component.cdi:main\" from local module loader @9e89d68 (finder: local module finder @3b192d32 (roots: C:\\JBoss\\EAP\\jboss-eap-6.4\\modules,C:\\JBoss\\EAP\\jboss-eap-6.4\\modules\\system\\layers\\fuse,C:\\JBoss\\EAP\\jboss-eap-6.4\\modules\\system\\layers\\soa,C:\\JBoss\\EAP\\jboss-eap-6.4\\modules\\system\\layers\\base))]"}}
22:42:51,419 ERROR [org.jboss.as.server] (management-handler-thread - 4) JBAS015870: Deploy of deployment "myapplication-0.0.1-SNAPSHOT.war" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"myapplication-0.0.1-SNAPSHOT.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"myapplication-0.0.1-SNAPSHOT.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"myapplication-0.0.1-SNAPSHOT.war\"
Caused by: java.lang.NoClassDefFoundError: org/apache/camel/core/osgi/utils/BundleContextUtils
Caused by: java.lang.ClassNotFoundException: org.apache.camel.core.osgi.utils.BundleContextUtils from [Module \"org.apache.camel.component.cdi:main\" from local module loader @9e89d68 (finder: local module finder @3b192d32 (roots: C:\\JBoss\\EAP\\jboss-eap-6.4\\modules,C:\\JBoss\\EAP\\jboss-eap-6.4\\modules\\system\\layers\\fuse,C:\\JBoss\\EAP\\jboss-eap-6.4\\modules\\system\\layers\\soa,C:\\JBoss\\EAP\\jboss-eap-6.4\\modules\\system\\layers\\base))]"}}
22:42:53,163 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment myapplication-0.0.1-SNAPSHOT.war (runtime-name: myapplication-0.0.1-SNAPSHOT.war) in 1740ms
22:42:53,163 INFO [org.jboss.as.controller] (management-handler-thread - 4) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."myapplication-0.0.1-SNAPSHOT.war".POST_MODULE
将包含骆驼上下文的spring文件命名为something-camel-context的正确方法是什么?