Tomcat如何动态加载class及遇到的错误

转载:http://ceapet.com/blog/index.php?option=com_content&view=article&id=205:tomcatclass&catid=38:java&Itemid=64

找到tomcat\conf\server.xml,在

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

下加入这一行
        <Context  path="/demo" docBase="C:/apache-tomcat-6.0.18/webapps/demo" reloadable="true" />

想要把tomcat设置成自动加载class,将reloadable="true"后,tomcat的确有反应,缺显示了错误,reload失败。& lt;/p>

Illegal access: this web application instance has been stopped already.  Could not load org.apache.xerces.impl.dtd.XMLNotationDecl.  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.
java.lang.IllegalStateException

查找日志找到,

Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! 

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

以为是 com.sun.faces.config.ConfigureListener配置有问题,弄来弄去,还是不行。

google 半天,也没有结果,终于看到一个大侠的提问,没有人回答,但大侠终究是大侠,自己搞明白了,还分享了答案,将xercesImpl-2.8.1.jar从webapp的lib下剪切到 tomcat的lib下,试一试,错误终于消失了。

回头看看这个包,错误信息中已经提示了,可自己当初怎么就是想不到呢?学艺不精啊。

原文地址:https://www.cnblogs.com/liuzhengdao/p/1501310.html