1

config hibernate と Java app (how Jira service) を試すと、次のエラーが発生します。

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>

-->

DB の SessionFactory を初期化しようとすると、次のエラーが発生します。

ourSessionFactory = new AnnotationConfiguration().configure("hibernate.cfg.xml").addAnnotatedClass(Navision.class).buildSessionFactory(); 

-->

4

2 に答える 2

0

xerxesImpl の他のバージョンを含めることは、一般的に苦痛のレシピです。アプリから xercesImpl または xml-apis jar を削除します。

于 2012-09-19T18:45:59.903 に答える
0

問題は解決しました。これまでに見られなかったいくつかの要因を発見しました。これらは、カスタム lib、how hibernate.core、dom4j などに含まれるパーサーでした。

于 2012-09-24T13:19:22.087 に答える