我正在使用 Jboss5,我正在尝试利用 Hibernate 和 Spring 来加载 spring dao。我收到一个异常,这似乎表明 jar 不兼容,但我不太确定发生了什么。我已经做了相当多的搜索,除了更改 JBOSS 版本之外,我似乎找不到特定的东西。我想知道是否有人遇到过类似的问题或找到了解决此问题的方法。我不应该将 spring 和 hibernate jar 放在耳朵里吗?
Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.parsers.DocumentBuilder.setEntityResolver(Lorg/xml/sax/EntityResolver;)V" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/springframework/beans/factory/xml/DefaultDocumentLoader, and the class loader (instance of ) for resolved class, javax/xml/parsers/DocumentBuilder, have different Class objects for the type org/xml/sax/EntityResolver used in the signature
最佳答案
您的 WAR 或 EAR 中可能有一个 XML API JAR 的副本,例如 Xerces、xml-apis
或类似的东西。这将与 JBoss 自己的发生(严重)冲突。
确保您的 WAR/EAR 在其 lib
目录中没有自己的 javax.xml
库副本。
关于java - jboss5 类加载器问题,spring 和 hibernate 尝试解析 applicationContext.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3998904/