Tomcat迁移至Websphere遇到的问题

[size=small]应用框架如下:Struts1.2+Spring2.0+Hibernate3.2

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

/**

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

*

* @param passPhrase

*/

public DesEncrypter(String passPhrase) {

try {

// Crate the key

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

iterationCount);

[color=red] SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(

keySpec);[/color]

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 JDK下PBEWithMD5AndDES没有这个参数(注意红色字体部分),报错,无法实例化!如果使用了DES的加密,自己另想办法吧!IBM JDK的JavaDoc,找了好久没有找到!

过于严苛的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>

Filter与Servlet加载顺序
在Tomcat下工作久了,你会认为这不是个问题,但是Websphere下确实很灵异,过滤器会晚于Servlet加载,也就是说Tomcat与Websphere处理这个问题的时候是相反的,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();

[color=red] args.add((String)this.getServletContext().getAttribute(GlobalNames.APP_PKXNXQ));[/color]

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

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

} catch (Exception e) {

e.printStackTrace();

}

}

[/size]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值