WebSphere6.0下spring 的上下文不能加载tomcat加载正常的问题

gavin213 2008-03-20 10:19:46
目前用Spring+Axis 完成了一WS项目,在tomcat下测试并顺利完成需求功能,但在WebSphere下部署时出现无法加载上下文的问题,也即ApplicationContext无法初始化,致使整个WS工程无法使用。下面是配置文件及初始化部分源码,请各位指教一二:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>  
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext-service.xml, /WEB-INF/classes/applicationContext-dao.xml, /WEB-INF/classes/applicationContext-jdbc.xml
</param-value>
</context-param>

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>PIRCClient</param-value>
</context-param>

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/classes/log4j.properties</param-value>
</context-param>

<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>600000</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.util.WebAppRootListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
.......
<servlet>
<servlet-name>PIRCClientSysInit</servlet-name>
<servlet-class>com.dragonsoft.pircclient.sys.PIRCClinetSysInit</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext-service.xml, /WEB-INF/classes/applicationContext-dao.xml, /WEB-INF/classes/applicationContext-jdbc.xml
</param-value>
</context-param>

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>PIRCClient</param-value>
</context-param>

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/classes/log4j.properties</param-value>
</context-param>

<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>600000</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.util.WebAppRootListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
.......
<servlet>
<servlet-name>PIRCClientSysInit</servlet-name>
<servlet-class>com.dragonsoft.pircclient.sys.PIRCClinetSysInit</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

PIRCClientSysInit是随服务器启动加载上下文的入口,问题也出在这里,其代码如下:
PIRCClientSysInit.java:
package com.dragonsoft.pircclient.sys;   

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.dragonsoft.pircclient.service.SysConfigureBufferedService;

public class PIRCClinetSysInit extends HttpServlet {

/**
*
*/
private static final long serialVersionUID = -2344733689247434124L;
static private Logger log = Logger.getLogger(PIRCClinetSysInit.class);

/**
* 容器启动时进行初始化
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {

log.info("系统开始初始化...");
ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
//WebSphere下会停留此处
log.info("系统初始化上下文结束...");
ServiceLocator.init(ctx);
//系统参数初始化
SysConfigureBufferedService.init();
log.info("系统初始化结束!");
}

}





在WebSphere下该WS工程日志会一直停留在“系统开始初始化...”,不会再向下进行进一步初始化,而在tomcat下不会存在这个问题。估计是ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());加载的问题,请了解的不吝赐教,谢谢~!
我WebSphere是6.0.
把ContextLoaderListener 改为ContextLoaderServlet实现,同样解决不了问题...
...全文
66 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
gavin213 2008-03-20
  • 打赏
  • 举报
回复
没人碰到过这种情况吗?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧