weblogic websphere 和 liberty profile 在使用struts2中遇到的URLClassLoader [struts2CleanupFilter]未装入
来源:互联网 发布:京东双十一实时数据 编辑:程序博客网 时间:2024/06/08 06:13
项目在tomcat下启动没有问题,但是部署到weblogic后就报错:
[ERROR ] SRVE0321E: 在启动期间过滤器 [struts2CleanupFilter] 未装入。
Filter [struts2CleanupFilter]: could not be initialized
[ERROR ] SRVE0321E: 在启动期间过滤器 [action2] 未装入。
Filter [action2]: could not be initialized
[ERROR ] SRVE0321E: 在启动期间过滤器 [action2] 未装入。
Filter [action2]: could not be initialized
<2010-4-20 下午02时54分57秒 CST> <Error> <HTTP> <BEA-101165> <Could not load use
r defined filter in web.xml: org.apache.struts2.dispatcher.FilterDispatcher.
Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Di
spatcher.java:371)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.
java:213)
at weblogic.servlet.internal.FilterManager$FilterInitAction.run(FilterMa
nager.java:329)
Truncated. see log file for complete stacktrace
Error loading configuration file struts.xml - [unknown location]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loa
dDocuments(XmlConfigurationProvider.java:165)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.ini
t(XmlConfigurationProvider.java:130)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContai
ner(DefaultConfiguration.java:155)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
ConfigurationManager.java:55)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Di
spatcher.java:371)
Truncated. see log file for complete stacktrace
unable to attain an URLClassLoader - [unknown location]
at com.opensymphony.xwork2.util.ClassPathFinder.findMatches(ClassPathFin
der.java:80)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loa
dConfigurationFiles(XmlConfigurationProvider.java:908)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loa
dDocuments(XmlConfigurationProvider.java:161)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.ini
t(XmlConfigurationProvider.java:130)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContai
ner(DefaultConfiguration.java:155)
Truncated. see log file for complete stacktrace
>
这种问题最好的解决办法就是修改你的struts.xml配置文件include里面的通配符*
有多少个文件就include多少个文件,不要采用通配符。
因为我跟踪了一下代码,发现报这个错误在于xwork的ClassPathFinder.findMatches方法里取得当前classloader的方式是ClassLoader loader = Thread.currentThread().getContextClassLoader();
在tomcat环境下取到的是URLClassloader的实例,而在weblogic下面却是weblogic.utils.classloaders.ChangeAwareClassLoader ,weblogic有自己的classLoader机制,因此导致了错误。我觉得解决此类问题除非weblogic自身去解决,比如继承URLClassLoader等。
如果你自己尝试解决,即使解决了,可能也会出现这样那样的问题。因此,还是按照最普通的方式,老老实实的将所有的文件都一个一个include进来吧。
话说鼎鼎大名struts2问世以来,已经不少人达到精通了(JAVA面试简历中99%可见),可是此问题翻阅了全球资料,也未找到合理的解决办法,只能叹息!叹息你们解决了问题的孙子不拿出来共享!我在此处深深的诅咒你们!诅咒你们ROLL点不过2!!对于主动上门咨询的,抱歉,哥最近很忙!
由于项目使用到这玩应,虽然个人不认为一个好东西,在艰难的搭建道路中,磕磕碰碰终于迎来一个崭新且四不像的版本,取其名曰struts1.5! 其实不过是吧strtus2改的面目全非,主要原因找不到可以说服自己不去改的理由。哪为什么要改?当然是有BUG、有性能问题、对于项目有部分不合理地方等等等……哪为什么要改这么多地方呢?我也无语了!!为什么不自己写框架?可能我还不够火候吧……玩笑到此,话入正题。
抽空继续补帖,本篇只针对strtus而言,当然你愿意一起分享时!如果对您有所帮助,请疯狂点击本人发布的下载,为俺混点分,俺在这里祈祷你的架构一切正常,否则~~!!无风也起浪!!
Weblogic下struts.xml文件通配符问题
Weblogic12C(其他版本估计一个德行)
struts2.3.3
玩~咱就都玩个最新的
声明:且只实验了weblogic环境下,其他环境未进行测试,相信结果差不多,要么没问题,要么有问题~~~具体错误现象与错误堆栈就不多说了,相信知道是通配符造成错误的童鞋们已经很清楚具体错误信息了,好!下面我就详细且啰嗦的阐述一下真正的错误原因
很多网友认为是垃圾weblogic造成的,开始本人也以为,一致暗自辱骂~~联系了oracle工程师的答复是:weblogic却是不支持*号通配符,因为考虑到安全问题,还称weblogic是标准的安全机制。哇!好有成就感,以为构建的项目相当安全了。
问题还是要解决啊,怎么办?网上找不到,google?总被屏蔽啊,怎么总有人搜我国关键字呀,无聊!Baidu?竞价太多,翻页手指头都肿了,自己看代码吧!
当看完struts2源码后(错了,应该是xwork2)才深深的体会到weblogic工程师的辛苦,我终于理解他了,都是出来混饭吃的。本人在此郑重声明一个问题:并非weblogic不支持通配符,而是从laod class开始就没有遵守JDK接口规范,换句话说就是,人家有自己实现底层的机制,不和你JDK扯。哪像apache一类的标准组织,还遵守JDK标准……咔!问题原因出来了,struts遵守了JDK标准,从而可以在标准的apache平台运行,那么当不遵守标准时就一定抛错么?答案是:不一定当然!好!请跟着还算清晰的节奏走,但愿你能够跟得上!
首先找到类:
- com.opensymphony.xwork2.config.providers.XmlConfigurationProvider
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider
然后找到找到方法:
- private List<Document> loadConfigurationFiles(String fileName,Element includeElement)
private List<Document> loadConfigurationFiles(String fileName,Element includeElement)好,往下拉,拉啊啦看到:
- if ("include".equals(nodeName))
if ("include".equals(nodeName))位置,咋这么熟悉呢?焕然大悟了吧!我们就从这里开始,也从这里结束吧!
呦还判断了这玩应哦
- if (includeFileName.indexOf('*') != -1)
if (includeFileName.indexOf('*') != -1)咋才一个星呢,不是一下写俩**是代表多层目录么?看来解析目录的代码还不错!
设置断点启动weblogic,果然断点已经跟踪掉,哇~~掌声!按F6,我按!我按!……哎,报错了:
- wildcardFinder.findMatches();
wildcardFinder.findMatches();报出unable to attain an URLClassLoader
关了服务,再来,我按!小心进入findMatches方法,我靠原来是这个类:
- com.opensymphony.xwork2.util.ClassPathFinder
com.opensymphony.xwork2.util.ClassPathFinder并发现了错误提示是
- new XWorkException("")
new XWorkException("")搞出来的,继续跟踪
- getURLClassLoader()
getURLClassLoader()方法,哎~~太简单,私有内部类,我了个去的,看下面有趣的代码:
臭小子敢偷钱!换我钱!胖揍!
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
ClassLoader loader = Thread.currentThread().getContextClassLoader();带人儿的~揣兜里暗笑,这也不是我的钱啊!我靠,我找你爹要去!
- if (!(loader instanceof URLClassLoader))
if (!(loader instanceof URLClassLoader))找到他爹继续胖揍!还钱!
- loader = ClassPathFinder.class.getClassLoader();
loader = ClassPathFinder.class.getClassLoader();又一张带人儿的,我靠,编号一样的!假钱!
- if (loader instanceof URLClassLoader)
if (loader instanceof URLClassLoader)看来真不是你们偷的,抱歉我闪!
- return ucl;
return ucl;至此所有真想已经浮出水面,错误的关键就在于此。
下面简单说下本人改造方式,为了保证不修改原有功能类的基础上进行改造,增加个方法:
- public Vector<String> findMatches(URI strutsURI)
public Vector<String> findMatches(URI strutsURI)并复制findMatches()方法中所有代码进行修改,findMatches()中代码可以删了~~~只要加句
- return findMatches(null);
return findMatches(null);就可以了。
修改逻辑代码为:
- URL[] parentUrls = null;
- if (cl == null) {
- if (null != strutsURI) {
- parentUrls = new URL[1];
- try {
- parentUrls[0] = strutsURI.toURL();
- } catch (MalformedURLException e) {
- throw new XWorkException("unable to attain an URLClassLoader");
- }
- }
- } else {
- parentUrls = cl.getURLs();
- }
URL[] parentUrls = null;if (cl == null) { if (null != strutsURI) { parentUrls = new URL[1]; try { parentUrls[0] = strutsURI.toURL(); } catch (MalformedURLException e) { throw new XWorkException("unable to attain an URLClassLoader"); } }} else { parentUrls = cl.getURLs();}搞定!还差点,这么写好像没什么用~~~~继续!回头修改调用类。
- wildcardMatches = wildcardFinder.findMatches(url.toURI().resolve(url.getPath().replaceAll(fileName, "")));
wildcardMatches = wildcardFinder.findMatches(url.toURI().resolve(url.getPath().replaceAll(fileName, "")));哎呀!哎呀!我擦,找个对象好费劲啊,也不知道有更好的实现不~
目前我只扫描struts.xml父目录下的配置文件,也就是classes下的,待我们项目上线了,再告知是否在其他操作系统下可行,如果有结果,感激不尽。至于你非要玩高深,吧配置文件加到jar里,抱歉自己想办法搞出几个适合你用的对象吧!小心struts.xml存放位置哦!这个可以通过web.xml修改位置与名字哦!如果默认strtus.xml名,其实就个三个XXX.xml静态字符串变量而已,吼吼!打完收工!别忘记给我刷点分哦!
- weblogic websphere 和 liberty profile 在使用struts2中遇到的URLClassLoader [struts2CleanupFilter]未装入
- websphere 和 weblogic 在iframe使用上的一点不同
- WebSphere Application Server Liberty Profile知识点概览
- URLClassLoader中loadClass的使用
- 如何准确高效创建weblogic域和websphere的profile(实用)
- websphere application server v8.5 liberty profile试用
- weblogic和websphere的jndi属性
- websphere和weblogic
- WebSphere的Profile信息
- 在weblogic中配置和使用dataSource
- struts2 在 websphere 中 404 FileNotFoundException 错误
- JAVA中类的装载和装入
- 在Websphere中使用FineReport
- Struts2部署在Websphere上的问题
- IBM WebSphere Application Server 8.5 Liberty Profile苗条瘦身之道初探及剖析
- websphere liberty 装配 部署
- WebSphere Liberty 一瞥
- Websphere liberty cluster installation
- Crypto API加密通信流程
- c++异常 连续抛出异常
- hadoop 学习总结2
- 日志功能:Log4Net的配置与使用
- 图像处理与计算机视觉:基础,经典以及最近发展
- weblogic websphere 和 liberty profile 在使用struts2中遇到的URLClassLoader [struts2CleanupFilter]未装入
- iOS学习1:#pragma mark
- Redis源码学习2-内存管理
- 短信发送AZDG加密算法
- VBS ADODB操作帮助手册
- UVa:10986 Sending email
- hadoop writable的实现
- Linux suse x86_64 环境上部署Hadoop启动失败原因分析
- 日志功能:log4Net