`
gstarwd
  • 浏览: 1490279 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

从tomcat 迁移到 WebSphere 经验总结(修改)

    博客分类:
  • SSH
阅读更多

从tomcat 迁移到 WebSphere 经验总结(修改)

我们的项目使用的是 web work+spring + jsf+dwr  ,项目在tomcatweblogic部署 均无问题,
我的具体遇到的困难,大家可以看贴http://www.webspherechina.net/club/viewthread.php?tid=2440&extra=page%3D1
但是最近迁移 到 websphere 6.1.0.3了,出现许多问题,现在拿出来,整理与大分享
    1. 在迁移过程中,出现的第一个导常:“java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml !”。造成这个异常的原因,是有我web.xml文件 有 两处同代码,都对org.springframework.web.context.ContextLoader上下文进行了加载,于量在spring加 载时,就会报错,对于spring来讲,不允许加载两个上下引用,关于这点,大概可以参考 org.springframework.web.context.ContextLoaderListener源码就知道怎么回是了!
   2.spring配置文件,出错会报“ nested exception is org.xml.sax.SAXParseException: cvc-elt.1:找不到元素“beans”的声明。 ”,解决办法我参考了论坛中《websphere 中 spring 的问题 》一文,现在将原因引入进来,供大家参考:
         spring配置文件  引入DTD这种方式在websphere 6.1 下不成功,必须改成 使用schema这种方式。
DTD:
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
   <beans default-autowire="byName">


SCHEMA:
   <?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-2.0.xsd "
       default-autowire="byName">
         default-autowire="byName">
    3.在webm.xml中采用DTD 2.4规范中加载spring的话,必须使用以下方式:
       <servlet>
    <servlet-name>SpringContextServlet</servlet-name>
    <servlet-class>
     org.springframework.web.context.ContextLoaderServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>   
   
    4.在我迁移过程中,还遇到这样一个比较头痛的问题,搞好几天才找到问题:“servlet debugjsp 抛出的 init() 异常:java.lang.ClassCastException: com.ibm.ws.classloader.CompoundClassLoader incompatible with java.net.URLClassLoader
        第一,就是应用程序 jar类加载机制与webshere类加载机制冲突造成,关于这点解决办法,就是更改webshere 服务     器设置或 应用 程序 的设置。一般情况不建议不更改webshere的设置,至于如何修改设置类加载顺序,可以与论贴,很简单的,所以在不此不做详细描述。
        第二种情况比较麻烦,就是工程中存在jar冲突,造成上面的异常,解决的办法就是将简化web.xml,逐个加载自己需要的模块,就可以找问题的原 因,我当时解决这个问题,就是这样,一次次改,最终发现在web.xml这段代码在加载jar时,造在上面的异常,以下是代码片断
     <servlet>
    <servlet-name>debugjsp</servlet-name>
    <description>Added by JBuilder to compile JSPs with debug info</description>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
      <param-name>classdebuginfo</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
  </servlet>  
    在自己工程下 compiler.jar  jasper-runtime.jar 存在两个jar ,至此,根本原因找到,因为在web.xml 配置了那段代码
造成应用程序加载了   compiler.jar  jasper-runtime.jar       两个jar包,删除多余代码和jar包,问题即解决。
     

    5.在webshere6.1中对web.xml有严格的语法检测,,一定要按照dtd规范来写,而tomcate在这点比较松,所以在布署的时候,需要注意一下(webshere6.1 支持DTD 2.3 DTD2.4,webshere5 支持2.3
          按以下元素顺<context-param>、<filter>、<list>、<servlet>、<servlet-mapping>,具体参考DTD规范
    6.大家在打成jar时,建议用ibm jdk1.5,不要sun jdk ,原因是保持兼容性
    7.关于tomcate迁移webshere其他的问题,可以参考这篇文章《程序从tomcat迁移至websphere的修改 》,另外有问题
可以及时发贴,把问题贴出来

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics