首页 > java > struts2重启tomcat后的错误的排除过程

struts2重启tomcat后的错误的排除过程

2010年3月26日 发表评论 阅读评论
项目使用架构struts2,hibernate3,spring2,在jdk6,tomcat5.5.12的环境下运行,曾经试过tomcat6,程序运行大概不到24小时就会报内存溢出,没办法又迁回到tomcat5.5.12,结果在不重启tomcat的情况下一直运行良好,但是使用restart就不能正常重启,必须先shutdown后再Start就OK了.

错误1: Could not load org.apache.log4j.spi.ThrowableInformation. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.

查看log4j的包,其它的log4j包全部删除,替换为log4j-1.2.9.jar后这个错误消失,原来包里有多个版本的log4j包;
 

错误2: SEVERE: Exception starting filter Struts2

Caught exception while loading file struts-default.xml – [unknown location]

Caused by: java.lang.ClassCastException:

org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration

解决方法:
移除项目目录中的xerces.jar
原因there was a conflict between tomcat’s internal XML parser and the xerces I was using inside my project.

这样可以重启了.

问题3重启后,使用浏览器访问时正常,只有使用lucene查询时,报java.lang.OutOfMemoryError: Java heap space

Caused by: java.lang.OutOfMemoryError: Java heap space

at java.lang.AbstractStringBuilder.<init>(Unknown Source)

at java.lang.StringBuffer.<init>(Unknown Source)

at java.io.BufferedReader.readLine(Unknown Source)

at java.io.BufferedReader.readLine(Unknown Source)

at org.wltea.analyzer.dic.Dictionary.loadMainDict(Dictionary.java:95)

Java heap space错误,应该是存在内存泄露了,根据异常提示信息,先不考虑java的库,只看第三方和自己的代码,
 org.wltea.analyzer.dic.Dictionary.loadMainDict(Dictionary.java:95)

这里就需要看这个方法到底干什么呢,原来我使用了IKAnalyzer3.2.0Stable 分词,换了其它的分词就没异常了,IK的分词作者给我的回复是这样的:

对于你说的问题,不知道算是IK的问题,还是算Tomcat的classloader的问题。这里我把问题的原因说明一下:
在IK中,由于词典需要占用较大的内存空间,约27M,因此词典采用了私有静态单例模型,确保只有一个实例在内存中。Tomcat在处理动态热部署的时候,对class的reload一直存在缺陷,造成先前的静态词典内存没有清除,才造成了OOM的错误。毕竟Tomcat不是一款商用的APP Server,而它在控制台上的功能相对薄弱,不建议使用它的热部署功能,如果需要,建议使用web sphere等专业的商用服务器平台.
非常感谢作者给我的回复,我目前的条件只能使用tomcat和 IKAnalyzer3分词,我觉得这个分词挺符合我的分词要求,正在寻找解决办法,有了在续写.
 
参考:
http://old.nabble.com/org.apache.xerces.parsers.XML11Configuration-cannot-be-cast-to-org.apache.xerces.xni.parser.XMLParserConfiguration-td14108368.html
分类: java 标签: , 7,291 次阅读
原文链接:http://www.wenhq.com/article/view_435.html
欢迎转载,请注明出处:亲亲宝宝
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.