Hibernate: das Dokument ist ungültig: keine Grammatik gefunden

Beim instanziieren ich Hibernate mit dem folgenden code:

        Configuration configuration = new Configuration();
        configuration.configure();
        serviceRegistry = new ServiceRegistryBuilder().applySettings(
                configuration.getProperties()).buildServiceRegistry();
        sessionFactory = configuration.buildSessionFactory(serviceRegistry);

Habe ich die folgenden Ausnahmen:

org.xml.sax.SAXParseException: Dokument ist ungültig: keine Grammatik gefunden.,
org.xml.sax.SAXParseException: Dokument-root-element
"hibernate-Konfiguration", muss mit DOCTYPE-root "null".
Verursacht durch: org.hibernate.MappingException: ungültige Konfiguration
bei org.hibernate.cfg.- Konfiguration.doConfigure(Configuration.java:2014)
bei org.hibernate.cfg.- Konfiguration.konfigurieren(die Konfiguration.java:1931)
bei org.hibernate.cfg.- Konfiguration.konfigurieren(die Konfiguration.java:1910)
bei com.Fußball.system.HibernateUtil.(HibernateUtil.java:23)
... 1 mehr
Verursacht durch: org.xml.sax.SAXParseException: Dokument ist ungültig: keine Grammatik gefunden.

Verwende ich die folgenden hibernate.cfg.xml - Datei mit Hibernate 4.1.6:

<?xml version='1.0' encoding='utf-8'?>

<hibernate-configuration
    xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
    xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <session-factory>
        <!-- Database connection settings -->
        <property name="connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
        <property name="connection.url">jdbc:derby://localhost:1527/K:\db</property>
        <property name="connection.username"></property>
        <property name="connection.password"></property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.DerbyDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache -->
        <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>
    </session-factory>
</hibernate-configuration>

Was kann ich tun, um diese zu beseitigen Ausnahme?

InformationsquelleAutor Sydney | 2012-09-05
Schreibe einen Kommentar