Развернуть Fuse Camel Project на EAP
Я создаю простой проект Camel с веб-службой SOAP, который записывает файл и отправляет ответ: он упакован в виде пакета, и я успешно развернул его на Karaf, источник которого можно найти здесь.
Затем я хотел бы преобразовать этот проект в модуль WAR и развернуть его на Fuse на EAP: следуя этим инструкциям
Apache Camel: руководство по использованию Camel в веб-приложении
Я изменил (в 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)
но я думаю, что это только предупреждение.
У кого-нибудь есть идеи?
заранее спасибо
1 ответ
Исключение "должен иметь четный номер URI" связано с тем, что у вас есть лишняя запись для camel-cxf-spring.xsd
в конце xsi:schemaLocation
,
Возможно, вам будет удобнее основывать свой код на примере Camel Tomcat CXF, поскольку он демонстрирует, как настроить CXFServlet
в web.xml. Вам нужно это, если вы хотите, чтобы потребитель 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>
Если вы используете Fuse на EAP 7.0 или 7.1, вы можете избежать Spring ContextLoaderListener
а также CXFServlet
так как сервер приложений позаботится о загрузке Spring & CXF для вас. Здесь есть пример проекта.