运行测试程序时有如下信息
 INFO  net.sf.hibernate.cfg.Configuration  - configuring from resource: /hibernate.cfg.xml INFO  net.sf.hibernate.cfg.Configuration  - Configuration resource: /hibernate.cfg.xml
这说明configuration.configure().buildSessionFactory();能正确执行了吧
映射文件也能够读取
可为什么还出现Not binding factory to JNDI, no JNDI name configured 的错误???
还有 null<-org.dom4j.tree.DefaultAttribute@18f51f [Attribute: name resource value "Customer.hbm.xml"]
测试过程中发现 session能生成 可session.beginTransaction();不能执行
为什么啊??
找了一天的时间了都没有找到原因

解决方案 »

  1.   

     null <-org.dom4j.tree.DefaultAttribute@18f51f   [Attribute:   name   resource   value   "Customer.hbm.xml"] 
    你有这个映射文件吗?
    如果没有就在hbm.cfg.xml里面去掉.IT资源网,Java/J2EE技术教程
      

  2.   

    Customer.hbm.xml:
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"><hibernate-mapping>
      <class name="springpro.Customer" table="CUSTOMERS">
         
      
        <id name="id" column="ID" type="long">
          <generator class="increment"/>
        </id>
        <property name="name"  column="NAME"  type="string" not-null="true" />  
        <property name="password"  column="PASSWORD"  type="string" not-null="true"/> 
        <property name="sex"       column="SEX"       type="character"/> 
        <property name="email"     column="EMAIL"     type="string" not-null="true" /> 
        <property name="telePhone"     column="TELEPHONE"     type="string" /> 
        <property name="fixPhone"     column="FIXPHONE"     type="string" /> 
        <property name="address"   column="ADDRESS"   type="string" /> 
        <property name="registeredTime" column="REGISTERED_TIME"  type="timestamp"/>  
         </class></hibernate-mapping>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-2.0.dtd"><hibernate-configuration>    <session-factory>        <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>        <!-- Mapping files -->
            <mapping resource="Customer.hbm.xml"/>    </session-factory></hibernate-configuration>
      

  3.   

    <mapping resource="Customer.hbm.xml" />
      

  4.   

               <mapping   resource="Customer.hbm.xml"/> 这样
               <mapping   resource="包名/子包名/Customer.hbm.xml"/> 
      

  5.   

    我怎么感觉这个hibernate.cfg.xml: 少了多太的东西了吧...
      

  6.   

    在补充之中啊
    现在改用spring的HibernateDaoSupport了
      

  7.   

    数据源在那里呢?读取数据源需要用到JNDI机制啊