我有多个WAR
s 都使用 aCXFServlet
来处理所有请求和Spring
配置。
他们都有一个相似的web.xml
(是的,它OSGi
也在):
<web-app id="app1">
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
</context-param>
<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>app1</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>app1</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
它们都共享一个共同的Spring
配置(common-rest.xml
):
<beans>
<import resource="classpath:META-INF/cxf/cxf.xml" />
<!-- For brevity I left out jaxRSProviders and jaxRSInInterceptors lists definitions -->
<bean id="baseJaxRSServer"
abstract="true"
lazy-init="false"
class="org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser.SpringJAXRSServerFactoryBean"
init-method="create"
p:address="${http.server}/"
p:providers-ref="jaxRSProviders"
p:inInterceptors-ref="jaxRSInInterceptors" />
</beans>
它们都具有类似的特定Spring
配置:
<beans>
<import resource="classpath:META-INF/app/common-rest.xml" />
<!-- For brevity I left out app1ServiceBeans list definition -->
<bean id="app1JaxRSServer"
parent="baseJaxRSServer"
p:serviceBeans-ref="app1ServiceBeans" />
</beans>
问题是,当我现在部署第一个应用程序时,它看起来还不错,但是基本上看不到所有其他应用程序绑定。似乎尽管所有应用程序都有单独的Spring
上下文和单独的CXF
服务器和单独的CXF
总线,但它们仍然不知何故会感到困惑,并且每个应用程序都被分配了一个org.apache.cxf.transport.Destination
- 来自第一个捆绑包的那个。有谁知道这怎么可能?
CXF:2.6.2,弹簧:3.1.4,卡拉夫:2.3.1