Hibernate和JBoss的SaxParser错误-版本冲突?

Hibernate和JBoss的SaxParser错误-版本冲突?,hibernate,jboss5.x,saxparser,Hibernate,Jboss5.x,Saxparser,我正在使用JBoss5.1.0.GA和Hibernate 当我尝试连接到数据库时,出现以下错误 10:21:03,042 INFO [Version] Hibernate Commons Annotations 3.1.0.GA 10:21:03,049 INFO [Configuration] configuring from resource: /hibernate.cfg.xml 10:21:03,049 INFO [Configuration] Configuration reso

我正在使用JBoss5.1.0.GA和Hibernate

当我尝试连接到数据库时,出现以下错误

10:21:03,042 INFO  [Version] Hibernate Commons Annotations 3.1.0.GA
10:21:03,049 INFO  [Configuration] configuring from resource: /hibernate.cfg.xml
10:21:03,049 INFO  [Configuration] Configuration resource: /hibernate.cfg.xml
10:21:03,077 INFO  [STDOUT] Warning: Caught exception attempting to use SAX to load a SAX XMLReader 
10:21:03,077 INFO  [STDOUT] Warning: Exception was: java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader
10:21:03,077 INFO  [STDOUT] Warning: I will print the stack trace then carry on using the default SAX parser
10:21:03,077 ERROR [STDERR] java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader
10:21:03,078 ERROR [STDERR]     at org.xml.sax.helpers.XMLReaderFactory.loadClass(Unknown Source)
10:21:03,078 ERROR [STDERR]     at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)
10:21:03,078 ERROR [STDERR]     at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)
10:21:03,078 ERROR [STDERR]     at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
10:21:03,078 ERROR [STDERR]     at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
10:21:03,078 ERROR [STDERR]     at org.dom4j.io.SAXReader.read(SAXReader.java:435)
10:21:03,078 ERROR [STDERR]     at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
然后

我有以下依赖项:-

hibernate注释3.4.0.GA hibernate commons注释3.1.0.GA hibernate core 3.3.0.SP1


我怀疑jboss库中的jar与依赖项中的jar之间存在冲突。有人能告诉我可能是什么吗?

我在JBoss5.0.1中运行Hibernate 4.0.0.CR6时遇到了同样的错误

Hibernate解析配置文件所需的解析器似乎是由jboss认可的libraries/lib/annowed/xercesImpl.jar提供的,Hibernate的xml API依赖性以某种方式干扰了它们

在我的例子中,没有在生成的archive.war中打包XMLAPI.jar就解决了这个问题。 为此,我在生成归档文件的项目的.pom中覆盖了依赖项的范围,而在其他地方覆盖则不行,因为提供的范围是不可传递的:

<dependency>
  <groupId>xml-apis</groupId>
  <artifactId>xml-apis</artifactId>
  <version>1.0.b2</version>
  <scope>provided</scope>
</dependency>

您是否在应用程序中打包hibernate JAR?如果是,为什么?我们有范围编译的hibernate依赖项。如果我删除了依赖项,那么mvn clean安装将失败它在jaxb schemagen上失败:为每个数据模型类生成一个类不存在消息如果使用提供的作用域怎么办?也尝试过了:-它不会编译。和以前一样的原因。
<dependency>
  <groupId>xml-apis</groupId>
  <artifactId>xml-apis</artifactId>
  <version>1.0.b2</version>
  <scope>provided</scope>
</dependency>