在Struts 2+Hibernate开发遇到了Struts2+JDK 6的冲突问题,具体信息如下:
出错信息: Illegal access: this web application instance has been stopped already. Could not load org.xml.sax.SAXException. 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.
现象: 第一次能运行, reload就不行. 启动不行.
解决思路: 排除法.
先试了Struts2自带的blank包, 没问题.
那基本可断定是其他jar包有冲突, 应该是XML解析包有冲突.
检查发布后的WEB-INF/lib有两个XML解析包: xml-apis.jar和xerces-2.6.2.jar
这种错误真正原因不是JDK 6和Struts 2冲突, 而是 MyEclipse Hibernate 类库中多了两个或者使用JDK 1.5来启动Tomcat 6.
方案1的详细操作步骤:
a. 先把MyEclipse Hibernate 3.2 Core Lib从BuildPath去掉;
b. 不要重新发布应用, 从发布后的目录复制全部的jar文件到开发工具下项目的WEB-INF\lib目录下, 不要复制其中的xml-apis.jar和xerces-2.6.2.jar.
c. 停止Tomcat, 重新发布应用或者删除发布后的目录下的WEB-INF\lib下的xml-apis.jar和xerces-2.6.2.jar.
小提示: MyEclipse 自带类库有很多问题, 建议读者自行下载官方网站jar包进行开发, 比较保险.