这几天做个项目有个问题困扰着,上网找答案一直没解决,最后还是自己调试解决了,痛苦啊
环境:
Spring+Struts+Hibernate+XFire
问题表现:
多个项目同时在同个tomcat服务器同时启动,tomcat在启动某个项目时卡死
Initializing WebApplicationContext for Struts ActionServlet 'action', module 这里卡死了
问题初步分析:
两个项目 一个为webservice服务提供者ProviderProject 一个为webservice客户端ClientProject
服务器在加载ClientProject 的spring bean配置文件时遇到通org.codehaus.xfire.spring.remoting.XFireClientFactoryBean生成的bean。而在生成时需要的wsdl在ProviderProject上,但这个时候ProviderProject并未启动,ClientProject没法找到ProviderProject 上的wsdl,导致XFireClientFactoryBean阻塞,从而tomcat加载spring bean配置文件时卡死
CFIS_RemoteServiceContext.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" 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"> <!-- PMIS系统的服务 --> <bean id="PMIS_UserService" class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean"> <property name="serviceClass"> <value>com.cmis.service.PMIS_UserService</value> </property> <property name="wsdlDocumentUrl"> <value>http://localhost:8080/CMIS_PMIS/services/PMIS_UserService?wsdl</value> </property> </bean> <!-- 部分省略 --> </beans>
问题深入分析:
未作深入分析
解决方案:
不想浪费时间,用了最笨的方法,将ProviderProject 和 ClientProject分开两个服务器运行,先运行ProviderProject后运行ClientProject