Tomcat迁移至Websphere遇到的问题

应用框架如下:Struts1.2Spring2.0Hibernate3.2

JDK的差别

不得不说Java的思想造福了大众,但是过多的Jdk版本我们不知所从,IBMJDKSUN官方的JDK有一些区别,我不知道区别有多大,但是我确实碰见了,如下代码:

       /**

        * 注意这个方法在IBM JDK下有错误

        *

        * @param passPhrase

        */

       public DesEncrypter(String passPhrase) {

              try {

                     // Crate the key

                     KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt,

                                   iterationCount);

                     SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(

                                   keySpec);

                     ecipher = Cipher.getInstance(key.getAlgorithm());

                     dcipher = Cipher.getInstance(key.getAlgorithm());

 

                     // Prepare the parameter to the ciphers

                     AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt,

                                   iterationCount);

 

                     // Create the ciphers

                     ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);

                     dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);

              } catch (Exception ex) {

                     ex.printStackTrace();

              }

       }

IBM JDKPBEWithMD5AndDES没有这个参数(注意红色字体部分),报错,无法实例化!如果使用了DES的加密,自己另想办法吧!IBM JDKJavaDoc,找了好久没有找到!

过于严苛的DTD问题

一个很简单的Spring配置文件,Tomcat下没有任何问题,WebSphere下在加载这个文件的时候会提示找不到beans定义错误,为什么呢?

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"

    "http://www.springframework.org/dtd/spring-beans.dtd">

 

<beans>

……

</beans>

改成以下形式吧,不要问为什么!

<?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">

……

</beans>

FilterServlet加载顺序

Tomcat下工作久了,你会认为这不是个问题,但是Websphere下确实很灵异,过滤器会晚于Servlet加载,也就是说TomcatWebsphere处理这个问题的时候是相反的,Tomcat会先加载Filter,然后在加载你的Servlet,而Websphere,先处理Servlet,然后在处理Filter。以下代码中红色部分是在Filter中初始化的,在Websphere下,会取得null,而Tomcat很正常。

       /**

        * Initialization of the servlet. <br>

        *

        * @throws ServletException

        *             if an error occure

        */

       public void init() throws ServletException {

              try {

                     ApplicationContext context = Context.getContext(this

                                   .getServletContext());

                     ISingleGenericDAO tempDao = (ISingleGenericDAO) context

                                   .getBean("singleGenericHibernateDAO");

                     List args = new ArrayList();

       args.add((String)this.getServletContext().getAttribute(GlobalNames.APP_PKXNXQ));

                     List list = tempDao.find("from Jx0408 where xnxqh = ?", args);

                     this.getServletContext().setAttribute(GlobalNames.APP_XKKB, list);

              } catch (Exception e) {

                     e.printStackTrace();

              }

       }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值