当我尝试配置hibernate和java app(如何使用Jira服务)时,我有这个错误:
Warning: Caught exception attempting to use SAX to load a SAX XMLReader
[INFO] [talledLocalContainer] Warning: Exception was: java.lang.ClassCastException:org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader
[INFO] [talledLocalContainer] Warning: I will print the stack trace then carry on using the default SAX parser
[INFO] [talledLocalContainer] java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader
[INFO] [talledLocalContainer] at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:243)
[INFO] [talledLocalContainer] at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:194)
[INFO] [talledLocalContainer] at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)
[INFO] [talledLocalContainer] at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
[INFO] [talledLocalContainer] at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
[INFO] [talledLocalContainer] at org.dom4j.io.SAXReader.read(SAXReader.java:435)
[INFO] [talledLocalContainer] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
- >
Caused by: org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
[INFO] [talledLocalContainer] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1528)
[INFO] [talledLocalContainer] at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035)
Caused by: org.dom4j.DocumentException: SAX2 driver class org.apache.xerces.parsers.SAXParser does not implement XMLReader Nested exception: SAX2 driver class org.apache.xerces.parsers.SAXParser does not implement XMLReader
[INFO] [talledLocalContainer] at org.dom4j.io.SAXReader.read(SAXReader.java:484)
[INFO] [talledLocalContainer] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
[INFO] [talledLocalContainer] ... 14 more
- >
.... 我的hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/navision</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.generate_statistics">false</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">100</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.timeout">100</property>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hbm2ddl.auto">update</property>
</session-factory>
- &GT;
当我尝试为db启动SessionFactory时出现此错误:
ourSessionFactory = new AnnotationConfiguration().configure("hibernate.cfg.xml").addAnnotatedClass(Navision.class).buildSessionFactory();
- &GT;
答案 0 :(得分:0)
包括其他版本的xerxesImpl通常是一个痛苦的方法。从您的应用中删除任何xercesImpl或xml-apis jar。
答案 1 :(得分:0)
问题解决了。我找到了一些以前没见过的因素。 这些是包含在自定义lib中的解析器,hibernate.core,dom4j等等。