- 浏览: 54758 次
- 性别:
- 来自: 上海
最新评论
最近搭建了一个websphere5.1+spring2.0+struts2+hibernate3的框架,因为jdk1.4加websphere5.1环境中间碰到一些问题,网上的解决方案也不全,今天搞了一整天总算搞定了,现与大家分享下。
开发工具myeclipse6,先在tomcat4 jdk4上测试,然后部署到websphere5.1上测试通过。
步骤:
1.设置编译环境为jdk1.4
2.把自己代码中所有1.5的特性都改成1.4
3.web.xml改成servlet2.3规范的
4.lib包不要配缺了就行
spring和hibernate的包都是jdk1.4编译的,不需要修改,其中cglib用的是cglib-nodep-2.1_3.jar而不是cglib-2.1_3.jar
struts2由于是jdk1.5编译的需要用retrotranslator转换,工具在struts2目录下的backport目录中,struts2-core-j4-2.0.11.1.jar和xwork-j4-2.0.4.jar已经转好了,再自己转个struts2-spring-plugin-j4-2.0.11.1.jar就可以了,最后把backport-util-concurrent-3.0.jar,retrotranslator-runtime-1.2.2.jar和你转好的包扔到lib目录下,原来的删除。
这方面网上资料还是蛮多的,不明白的可以查找下。
5.websphere5.1兼容性问题
当你成功完成上述步骤后tomcat4已经可以跑了,然后部署到websphere5.1如果没有错误的话可以运行而且后台不报错,但是页面上报XXX.action路径找不到,这个花了我好多时间才搞定,网上也没找到具体解决方案。
原因:
DefaultActionMapper类中的getUri方法:
String getUri(HttpServletRequest request) { // handle http dispatcher includes. String uri = (String) request .getAttribute("javax.servlet.include.servlet_path"); if (uri != null) { return uri; } uri = RequestUtils.getServletPath(request); //System.out.println("url==========="+uri); //old:if (uri != null && !"".equals(uri)) { if (uri != null && uri.length() > 1) { return uri; } uri = request.getRequestURI(); return uri.substring(request.getContextPath().length()); }
发现上面注释掉的那句:
//System.out.println("url==========="+uri);
输出为"/",实际为"/XX/XX.action"看来是uri解析错误,猜想可能是
RequestUtils.getServletPath(request);
这个方法有bug,结果发现源代码没提供,所以只能在外层方法中改下了,重写了个过滤器。改完后成功运行。
解决方案如下,添加2个类
DefaultActionMapperCompaWebsphere51(修改了getUri后的判断)
/* * $Id: DefaultActionMapper.java 540141 2007-05-21 13:46:48Z mrdon $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.struts2.dispatcher.mapper; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.RequestUtils; public class DefaultActionMapperCompaWebsphere51 extends DefaultActionMapper { private static ActionMapper actionMapper = new DefaultActionMapperCompaWebsphere51(); public static ActionMapper getActionMapper(){ return actionMapper; } /** * modify uri compare * @param request * @return */ String getUri(HttpServletRequest request) { // handle http dispatcher includes. String uri = (String) request .getAttribute("javax.servlet.include.servlet_path"); if (uri != null) { return uri; } uri = RequestUtils.getServletPath(request); //System.out.println("url==========="+uri); //old:if (uri != null && !"".equals(uri)) { if (uri != null && uri.length() > 1) { return uri; } uri = request.getRequestURI(); return uri.substring(request.getContextPath().length()); } }
FilterDispatcherCompaWebsphere51(调用自己刚才重写的DefaultActionMapperCompaWebsphere51)
/* * $Id: FilterDispatcherCompatWeblogic61.java 476075 2006-11-17 08:28:30Z mrdon $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.struts2.dispatcher; import java.io.IOException; import javax.servlet.FilterChain; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.RequestUtils; import org.apache.struts2.dispatcher.mapper.ActionMapper; import org.apache.struts2.dispatcher.mapper.ActionMapping; import org.apache.struts2.dispatcher.mapper.DefaultActionMapperCompaWebsphere51; import com.opensymphony.xwork2.util.profiling.UtilTimerStack; public class FilterDispatcherCompaWebsphere51 extends FilterDispatcher { private static boolean serveStatic; public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; ServletContext servletContext = getServletContext(); String timerKey = "FilterDispatcher_doFilter: "; try { UtilTimerStack.push(timerKey); request = prepareDispatcherAndWrapRequest(request, response); ActionMapping mapping; ActionMapper actionMapper = DefaultActionMapperCompaWebsphere51.getActionMapper(); try { mapping = actionMapper.getMapping(request, dispatcher .getConfigurationManager()); } catch (Exception ex) { log.error("error getting ActionMapping", ex); dispatcher.sendError(request, response, servletContext, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); return; } if (mapping == null) { // there is no action in this request, should we look for a // static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) { resourcePath = request.getPathInfo(); } if (serveStatic && resourcePath.startsWith("/struts")) { String name = resourcePath.substring("/struts".length()); findStaticResource(name, request, response); } else { // this is a normal request, let it pass through chain.doFilter(request, response); } // The framework did its job here return; } dispatcher .serviceAction(request, response, servletContext, mapping); } finally { try { ActionContextCleanUp.cleanUp(req); } finally { UtilTimerStack.pop(timerKey); } } } private static final Log log = LogFactory .getLog(FilterDispatcherCompaWebsphere51.class); }
修改web.xml中原来的struts2的filter类
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcherCompaWebsphere51
</filter-class>
</filter>
之后就可以放在tomcat和websphere5.1上运行了。
本文只说明了遇到的一些问题的解决方案,如何配置struts2或spring或hibernate可以参考官方资料。
如有不明白的可以留言。
评论
2008-12-2 23:19:51 org.apache.commons.digester.Digester error 严重: Parse Error at line 10 column -1: 组件类型“uri”未被声明。 org.xml.sax.SAXParseException: 组件类型“uri”未被声明。 at org.apache.crimson.parser.Parser2.error(Parser2.java:3354) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1502) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667) at org.apache.crimson.parser.Parser2.parse(Parser2.java:337) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) at org.apache.commons.digester.Digester.parse(Digester.java:1765) at org.apache.catalina.startup.ContextConfig.tldScanStream(ContextConfig.java:929) at org.apache.catalina.startup.ContextConfig.tldScanJar(ContextConfig.java:863) at org.apache.catalina.startup.ContextConfig.tldScan(ContextConfig.java:810) at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:588) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:182) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3644) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:777) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:760) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:538) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:265) at org.apache.catalina.core.StandardHost.install(StandardHost.java:731) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:649) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:379) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:808) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:335) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1156) at org.apache.catalina.core.StandardHost.start(StandardHost.java:697) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1148) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:311) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2213) at org.apache.catalina.startup.Catalina.start(Catalina.java:484) at org.apache.catalina.startup.Catalina.execute(Catalina.java:371) at org.apache.catalina.startup.Catalina.process(Catalina.java:134) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:151) 2008-12-2 23:19:51 org.apache.commons.digester.Digester error 严重: Parse Error at line 11 column -1: 组件类型“listener”未被声明。 org.xml.sax.SAXParseException: 组件类型“listener”未被声明。 at org.apache.crimson.parser.Parser2.error(Parser2.java:3354) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1502) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667) at org.apache.crimson.parser.Parser2.parse(Parser2.java:337) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) at org.apache.commons.digester.Digester.parse(Digester.java:1765) at org.apache.catalina.startup.ContextConfig.tldScanStream(ContextConfig.java:929) at org.apache.catalina.startup.ContextConfig.tldScanJar(ContextConfig.java:863) at org.apache.catalina.startup.ContextConfig.tldScan(ContextConfig.java:810) at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:588) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:182) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3644) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:777) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:760) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:538) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:265) at org.apache.catalina.core.StandardHost.install(StandardHost.java:731) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:649) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:379) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:808) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:335) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1156) at org.apache.catalina.core.StandardHost.start(StandardHost.java:697) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1148) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:311) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2213) at org.apache.catalina.startup.Catalina.start(Catalina.java:484) at org.apache.catalina.startup.Catalina.execute(Catalina.java:371) at org.apache.catalina.startup.Catalina.process(Catalina.java:134) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:151)
上线的时候客户要求用了websphere6.1,我就直接部上来了,登陆的页面能看到,但是输入信息登陆后就弹出个页,说是:
Error 404: SRVE0190E:找不到文件: login.action
请问,这是什么原因啊?
相关推荐
根据提供的标题、描述以及部分内容,本文将详细解析与MYECLIPSE + STRUTS2 + SPRING4 + HIBERNATE4 + STRUCTS2S+OGNL + MYSQL_5.7.12相关的技术栈及其应用。这些技术在企业级开发中非常常见,能够帮助开发者构建高效...
本主题将深入探讨Spring 2.0、2.5版本的MVC特性和Portlet MVC的相关知识。 首先,Spring 2.0在MVC方面引入了显著的改进,包括: 1. **依赖注入(DI)**:Spring 2.0增强了对MVC组件的依赖注入支持,允许开发者更...
Websphere 5.1是IBM提供的一款企业级应用服务器,用于部署和管理Java应用程序。在本文中,我们将深入探讨如何在Websphere 5.1版本中进行应用部署,以及解决中文乱码问题。 首先,让我们详细了解Websphere 5.1的应用...
JEECMS使用目前java主流技术架构:hibernate3+struts2+spring2+freemarker。AJAX使用jquery和json实现。视图层并没有使用传统的JSP技术,而是使用更为专业、灵活、高效freemarker。 数据库使用MYSQL,并可支持orcale...
本篇将详细讲解如何在WebSphere 6.1服务器上配置MyEclipse 6.0.0.M1集成开发环境,并整合Struts2、Spring2和Hibernate3这三大流行框架,即SSH2(Struts2、Spring、Hibernate2)的集成过程。 首先,我们来了解...
在本示例中,我们将探讨如何在Spring框架中集成iBATIS,并且将这个集成应用部署到WebSphere 5.1服务器上,并提供一个基于Web服务的接口。首先,我们需要理解Spring和iBATIS的基本概念。 Spring是一个开源的Java企业...
3. 熟悉Spring的AOP和IOC概念,理解它们在Spring中的应用。 4. 掌握Hibernate的查询方式,理解load()和get()的区别。 5. 熟悉Tiles框架,它是如何实现Web页面模板化。 6. 对应用服务器的概念有所了解,例如BEA ...
本教程将详细阐述如何在LoadRunner 8.1中配置对WebSphere 5.1的监控,以获取全面的性能指标。 首先,我们需要理解LoadRunner与WebSphere集成的基本原理。LoadRunner通过Vuser(虚拟用户)模拟实际用户的操作,同时...
【标题】"jsr168 portlet"是基于Java标准JSR168实现的portlet应用,它结合了Struts2、Spring2.5和Hibernate3.3这三大流行框架,以构建可复用、模块化的Web应用程序。JSR168(Portlet API 1.0)为portlet开发提供了...
Spring 2.0开始支持portlet开发,这使得它可以在portlet容器中运行,如Liferay和Websphere Portal Server,拓宽了Spring的应用范围。 八、MVC测试 Spring提供了一套强大的测试框架,包括单元测试和集成测试工具,...
2. Spring 2.0 的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 更简单的XML配置 2.2.2. 新的bean作用域 2.2.3. 可扩展的XML编写 2.3. 面向切面编程(AOP) 2.3.1. 更加简单的AOP XML配置 2.3.2. 对@...
- Spring 2.0添加了对JSR-168 Portlet规范的支持,使得Spring可以用于portlet开发,适应portlet容器如Liferay和WebSphere Portal。 7. **国际化(I18N)支持** - 通过ResourceBundle和MessageSource接口,Spring ...
### Websphere IHS+Plugin 的 SSL 访问配置详解 #### 一、概述 在当前互联网环境下,安全成为越来越重要的考量因素。对于 Web 应用服务器而言,使用 SSL(Secure Sockets Layer)协议来加密数据传输是保障数据安全...
根据给定的文件信息,我们可以总结出以下几...以上总结了从标题、描述以及部分文件内容中提取的关键知识点,覆盖了Struts2、Spring、Hibernate等多个方面,旨在帮助读者更好地理解和掌握这些技术的核心概念及应用场景。
在使用WebSphere Application Server(WAS)部署基于Struts2.0的应用时,可能会遇到一些问题导致Struts2无法正常工作。这个问题通常表现为在尝试访问Struts2控制的页面时,返回HTTP 500错误,并且日志中显示"Filter ...
介绍这是一个利用以下技术的示例项目: WebSphere应用服务器8.5 JPA 2.0 冬眠SpringMVC 该项目的目的仅仅是演示如何集成这些技术。 有关更多信息,请查看我的博客文章, 为: : 项目准备参见doc / 0001_InitialDdl....
IBM+WebSphere+Studio+J2EE
IBM+WebSphere+Studio+J2EE应用开发_2.