Java 处理;Xerces地狱“;和雄猫
我们有多个java web应用程序,它们由tomcat托管。 一些应用程序包括xercesImpl jar,其他应用程序不包括xercesImpl.jar 为了简单起见,假设我们只有两个应用程序:Java 处理;Xerces地狱“;和雄猫,java,tomcat,xerces,Java,Tomcat,Xerces,我们有多个java web应用程序,它们由tomcat托管。 一些应用程序包括xercesImpl jar,其他应用程序不包括xercesImpl.jar 为了简单起见,假设我们只有两个应用程序: xxx.war->使用xerces yyy.war->不使用xerces 这两个应用程序都在启动时进行一些xml解析,并且只使用java.*和javax.*(不直接导入org.apache.xerces) 如果xxx.war首先启动,而yyy.war在尝试解析xml时出错: Caused by:
- xxx.war->使用xerces
- yyy.war->不使用xerces
Caused by: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:191)
at ca.icod.personne.adressePostale.RecuperateurFormat.createXMLReader(RecuperateurFormat.java:246)
at ca.icod.personne.adressePostale.RecuperateurFormat.parse(RecuperateurFormat.java:214)
... 127 more
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1856)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705)
at org.xml.sax.helpers.NewInstance.newInstance(NewInstance.java:82)
at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:228)
当应用程序以相反的顺序启动时,启动时没有问题。
我假设当xxx.war启动时,会找到xercesImpl,因此它的内部META-INF/services文件夹被读取,因此xerces被标记为要在JVM中使用的xml实现。然后,当yyy.war尝试为xml内容添加点时,JVM仍然认为它应该使用xerces,但这次它不在类路径上:ClassNotFoundException
我们希望逐步从应用程序中删除Xerce,因为jdk的默认实现似乎可以完成这项工作
但我们很难一次将Xerce从任何地方移除,也很难将托管Xerce支持的Web应用程序的tomcat服务器与托管xerces不支持的Web应用程序的tomcat服务器分开
我是错过了一些奇怪的事情还是这里有人解决了类似的问题