Tomcat迁移至Websphere遇到的问题

xiaoxiao2026-03-17  14

[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]
转载请注明原文地址: https://www.6miu.com/read-5046034.html

最新回复(0)