log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.MappingException: Could not read mappings from resource: src/Customer.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at Test.main(Test.java:14)
Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:431)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 7 more
Caused by: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
... 8 more
最近刚研究hibernate,有点迷糊了。哈。好象是配置文件没有配对还是怎么回事啊。出错了。。

解决方案 »

  1.   

    org.hibernate.MappingException: Could not parse mapping document in input stream 
    你配置文件有问题吧?
      

  2.   

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools.                   -->
    <hibernate-configuration><session-factory >
    <property name="connection.username">jirauser</property>
    <property name="connection.url">
    jdbc:jtds:sqlserver://192.168.1.78:1433/jiradb
    </property>
    <property name="dialect">
    org.hibernate.dialect.FrontBaseDialect
    </property>
    <property name="myeclipse.connection.profile">
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    </property>
    <property name="connection.password">1q2w3e</property>
    <property name="connection.driver_class">
    net.sourceforge.jtds.jdbc.Driver
    </property>
    <property name="show_sql">true</property><!-- 指定Customer的映射文件 -->
    <mapping resource="src/Customer.hbm.xml" /></session-factory></hibernate-configuration>
    bibernate.cfg.xml
      

  3.   

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"><hibernate-mapping>
        <class name="Customer" table="CUSTOMER">
            <id name="id" column="CID">
                <generator class="increment" />
            </id>
            <property name="username" column="USERNAME" />
            <property name="password" column="PASSWORD" />
        </class>
    </hibernate-mapping>
    customer.hbm.xml
      

  4.   

    呵呵。。很简单的一个例子。以前学过,但是好久没hibernate了。今天拿一个例子来练习,谁知道出那么多错。。哈哈
      

  5.   

    问题已经解决
    看看你时如何得到configuration对象的
    Configuration hf = HibernateSessionFactory.getConfiguration().configure();不对
    改为Configuration hf = HibernateSessionFactory.getConfiguration();
    就ok了
      

  6.   

    把src去掉就可以了吧  路径写错了