Error creating bean with name 'sessionFactory' defined in class path resource

时间:2022-11-12 08:57:02
2009-8-6 9:47:06 org.apache.catalina.core.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\MyEclipse 6.0\bin;D:\Program Files\MyEclipse 6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_6.0.1.zmyeclipse601200710\tomcat\bin
2009-8-6 9:47:06 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2009-8-6 9:47:06 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 637 ms
2009-8-6 9:47:06 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-8-6 9:47:06 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.13
2009-8-6 9:47:08 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2009-8-6 9:47:10 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingNotFoundException: resource: com/whda/entity/Immobility.hbm.xml not found
Caused by: org.hibernate.MappingNotFoundException: resource: com/whda/entity/Immobility.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:563)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1443)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:634)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1198)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1167)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-8-6 9:47:10 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2009-8-6 9:47:10 org.apache.catalina.core.StandardContext start
严重: Context [/hdDate] startup failed due to previous errors
2009-8-6 9:47:10 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2009-8-6 9:47:10 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2009-8-6 9:47:10 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2009-8-6 9:47:10 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/78  config=null
2009-8-6 9:47:10 org.apache.catalina.startup.Catalina start
信息: Server startup in 4119 ms


<?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">sa</property>
<property name="connection.url">
jdbc:sqlserver://localhost:1433;databaseName=hd
</property>
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="myeclipse.connection.profile">sql2005</property>
<property name="connection.password">leon</property>
<property name="connection.driver_class">
com.microsoft.sqlserver.jdbc.SQLServerDriver
</property>
<property name="show_sql">true</property>
<property name="connection.autocommit">true</property>
<!--  -->
<mapping resource="com/whda/entity/Immobility.hbm.xml" />
<mapping resource="com/whda/entity/Hdmain.hbm.xml" />
<mapping resource="com/whda/entity/Manhour.hbm.xml" />


</session-factory>

</hibernate-configuration>


<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<!-- 配置spring资源库 -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>com.whhd.hd.struts.ApplicationResources</value>
</property>
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml">
</property>
<!--  
<property name="mappingLocations"> 
       <list>
        <value>classpath*:com/whda/entity/Immobility.hbm.xml</value>
        <value>classpath*:com/whda/entity/Hdmain.hbm.xml</value>
        <value>classpath*:com/whda/entity/Manhour.hbm.xml</value>
       
           </list>
        </property>
        -->
</bean>

<!-- DAO -->
<bean id="hdmaindao" class="com.whhd.dao.HdmainDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="immobilityDAO" class="com.whhd.dao.ImmobilityDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="manhourDAO" class="com.whhd.dao.ManhourDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- BIZ -->

<bean id="ihmainImpl" class="com.whhd.biz.IHmainImpl">
<property name="hdmainDAO">
<ref bean="hdmaindao"/>
</property>
</bean>
<bean id="immobilityImpl" class="com.whhd.biz.ImmobilityImpl">
<property name="immobility">
<ref bean="immobilityDAO" />
</property>
</bean>
<bean id="manhourImpl" class="com.whhd.biz.ManhourImpl">
<property name="manhour">
<ref bean="manhourDAO"/>
</property>
</bean>
<!-- ACTION -->
<bean name="/main" class="com.whhd.struts.action.MainAction">
<property name="ihmainBiz">
<ref bean="ihmainImpl"/>
</property>
<property name="manhourBiz">
<ref bean="manhourImpl"/>
</property>
<property name="immobilityBiz">
<ref bean="immobilityImpl"/>
</property>
</bean>
</beans>

20 个解决方案

#1


上面写是entity路径问题,不过这个 应该是 hibernate 的 Configuration视图中add 自动生成的个路径 怎么会有错?

#2


Caused by: org.hibernate.MappingNotFoundException: resource: com/whda/entity/Immobility.hbm.xml not found
找不到这个映射文件啊 
看看路径什么的 
删除缓存试试
tomcat目录下的work文件夹下的内容全部删掉 
重启tom试试

#3


<mapping resource="com/whda/entity/Immobility.hbm.xml" />not found

#4


引用 3 楼 xinyung 的回复:
<mapping resource="com/whda/entity/Immobility.hbm.xml" />not found

我也知道 说是 这个路径问题错误,但是 这个是hibernate 的 Configuration视图 页面 里Add自动添加的 怎么可能呢

#5


引用 2 楼 nangonghaopeng 的回复:
Caused by: org.hibernate.MappingNotFoundException: resource: com/whda/entity/Immobility.hbm.xml not found
找不到这个映射文件啊
看看路径什么的
删除缓存试试
tomcat目录下的work文件夹下的内容全部删掉
重启tom试试

没有效果...路径 应该没有什么问题

#6


用目录试试,一个映射文件一个的配置多麻烦,直接配置路径,让它自己去找
<property name="mappingDirectoryLocations">
  <list>
    <value>classpath:/com/whda/entity</value>
  </list>
</property>

#7


用了spring就直接在spring的配置文件中写hibernate好了 就不用hibernate。cfg。xml了吧

#8


引用 7 楼 nangonghaopeng 的回复:
用了spring就直接在spring的配置文件中写hibernate好了 就不用hibernate。cfg。xml了吧

你们说的 我知道,虽然可以解决这个问题,不过在 调用ACTION的时候 就会出现
Hdmain is not mapped [FROM Hdmain]
这个错误,我怀疑 是不是 因为hibernate 将里面的entity的hbm.xml文件写如了spring 所以 就找不到了
所以 我就又返回来找这个问题的解决方法

#9


你用了spring 那么服务器启动的时候就会实例化那些类(从spring容器的配置文件中查找)
没有肯定就报错了啊

#10


引用 9 楼 nangonghaopeng 的回复:
你用了spring 那么服务器启动的时候就会实例化那些类(从spring容器的配置文件中查找)
没有肯定就报错了啊

难道 说是 非要把entity.hbm.xml 文件 写入applicationContext.xml文件里么?我记得以前做的程序没有这样的呀..是这次碰到的这样的问题

#11


<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>cn/csdn/domain/Person.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=true
hibernate.format_sql=true
</value>
</property>
</bean>
改成类似这样看看

#12


引用 11 楼 sangshusen_1988 的回复:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>cn/csdn/domain/Person.hbm.xml </value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=true
hibernate.format_sql=true
</value>
</property>
</bean>
改成类似这样看看

你这个是把hibernate跟spring的applicationContext.xml 写到一起去了
我就是想把
<property name="mappingResources"> 
<list> 
<value>cn/csdn/domain/Person.hbm.xml </value> 
</list> 
</property> 
再写回到hibernate 里...
hibernate 里 视图页面中添加ADD entity的hbm.xml 文件 就会报
Error   creating   bean   with   name   'sessionFactory '   defined   in   class   path   resource 并且说entity的路径不对

#13


2009-8-6 11:49:44 org.apache.catalina.core.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\MyEclipse 6.0\bin;D:\Program Files\MyEclipse 6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_6.0.1.zmyeclipse601200710\tomcat\bin
2009-8-6 11:49:45 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2009-8-6 11:49:45 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 631 ms
2009-8-6 11:49:45 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-8-6 11:49:45 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.13
2009-8-6 11:49:46 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2009-8-6 11:49:49 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.whha.entity.Hdmain
Caused by: org.hibernate.MappingException: Association references unmapped class: com.whha.entity.Hdmain
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2380)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2662)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1198)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1167)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-8-6 11:49:49 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2009-8-6 11:49:49 org.apache.catalina.core.StandardContext start
严重: Context [/hdDate] startup failed due to previous errors
2009-8-6 11:49:49 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2009-8-6 11:49:49 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2009-8-6 11:49:49 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2009-8-6 11:49:49 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31  config=null
2009-8-6 11:49:49 org.apache.catalina.startup.Catalina start
信息: Server startup in 4633 ms

#14


Error creating bean with name 'sessionFactory' defined in class path resource

#15


Error creating bean with name 'sessionFactory' defined in class path resource

#16


asm2.2.3jar这个包删掉就OK啦~~!

#17


回复于:2009-10-21 22:46:12asm2.2.3jar这个包删掉就OK啦~~! 
 
哥们,我也碰到这个问题,删除这个架包没用啊,

#18


用MyEclipse自带的tomcat试试看,我以前遇到跟你一样的问题,就是那样解决的。

#19


兄弟,你解决问题了吗?我也是这个问题啊

#20


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml这怎么解决啊

#1


上面写是entity路径问题,不过这个 应该是 hibernate 的 Configuration视图中add 自动生成的个路径 怎么会有错?

#2


Caused by: org.hibernate.MappingNotFoundException: resource: com/whda/entity/Immobility.hbm.xml not found
找不到这个映射文件啊 
看看路径什么的 
删除缓存试试
tomcat目录下的work文件夹下的内容全部删掉 
重启tom试试

#3


<mapping resource="com/whda/entity/Immobility.hbm.xml" />not found

#4


引用 3 楼 xinyung 的回复:
<mapping resource="com/whda/entity/Immobility.hbm.xml" />not found

我也知道 说是 这个路径问题错误,但是 这个是hibernate 的 Configuration视图 页面 里Add自动添加的 怎么可能呢

#5


引用 2 楼 nangonghaopeng 的回复:
Caused by: org.hibernate.MappingNotFoundException: resource: com/whda/entity/Immobility.hbm.xml not found
找不到这个映射文件啊
看看路径什么的
删除缓存试试
tomcat目录下的work文件夹下的内容全部删掉
重启tom试试

没有效果...路径 应该没有什么问题

#6


用目录试试,一个映射文件一个的配置多麻烦,直接配置路径,让它自己去找
<property name="mappingDirectoryLocations">
  <list>
    <value>classpath:/com/whda/entity</value>
  </list>
</property>

#7


用了spring就直接在spring的配置文件中写hibernate好了 就不用hibernate。cfg。xml了吧

#8


引用 7 楼 nangonghaopeng 的回复:
用了spring就直接在spring的配置文件中写hibernate好了 就不用hibernate。cfg。xml了吧

你们说的 我知道,虽然可以解决这个问题,不过在 调用ACTION的时候 就会出现
Hdmain is not mapped [FROM Hdmain]
这个错误,我怀疑 是不是 因为hibernate 将里面的entity的hbm.xml文件写如了spring 所以 就找不到了
所以 我就又返回来找这个问题的解决方法

#9


你用了spring 那么服务器启动的时候就会实例化那些类(从spring容器的配置文件中查找)
没有肯定就报错了啊

#10


引用 9 楼 nangonghaopeng 的回复:
你用了spring 那么服务器启动的时候就会实例化那些类(从spring容器的配置文件中查找)
没有肯定就报错了啊

难道 说是 非要把entity.hbm.xml 文件 写入applicationContext.xml文件里么?我记得以前做的程序没有这样的呀..是这次碰到的这样的问题

#11


<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>cn/csdn/domain/Person.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=true
hibernate.format_sql=true
</value>
</property>
</bean>
改成类似这样看看

#12


引用 11 楼 sangshusen_1988 的回复:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>cn/csdn/domain/Person.hbm.xml </value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=true
hibernate.format_sql=true
</value>
</property>
</bean>
改成类似这样看看

你这个是把hibernate跟spring的applicationContext.xml 写到一起去了
我就是想把
<property name="mappingResources"> 
<list> 
<value>cn/csdn/domain/Person.hbm.xml </value> 
</list> 
</property> 
再写回到hibernate 里...
hibernate 里 视图页面中添加ADD entity的hbm.xml 文件 就会报
Error   creating   bean   with   name   'sessionFactory '   defined   in   class   path   resource 并且说entity的路径不对

#13


2009-8-6 11:49:44 org.apache.catalina.core.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\MyEclipse 6.0\bin;D:\Program Files\MyEclipse 6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_6.0.1.zmyeclipse601200710\tomcat\bin
2009-8-6 11:49:45 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2009-8-6 11:49:45 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 631 ms
2009-8-6 11:49:45 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-8-6 11:49:45 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.13
2009-8-6 11:49:46 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2009-8-6 11:49:49 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.whha.entity.Hdmain
Caused by: org.hibernate.MappingException: Association references unmapped class: com.whha.entity.Hdmain
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2380)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2662)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1198)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1167)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-8-6 11:49:49 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2009-8-6 11:49:49 org.apache.catalina.core.StandardContext start
严重: Context [/hdDate] startup failed due to previous errors
2009-8-6 11:49:49 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2009-8-6 11:49:49 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2009-8-6 11:49:49 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2009-8-6 11:49:49 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31  config=null
2009-8-6 11:49:49 org.apache.catalina.startup.Catalina start
信息: Server startup in 4633 ms

#14


Error creating bean with name 'sessionFactory' defined in class path resource

#15


Error creating bean with name 'sessionFactory' defined in class path resource

#16


asm2.2.3jar这个包删掉就OK啦~~!

#17


回复于:2009-10-21 22:46:12asm2.2.3jar这个包删掉就OK啦~~! 
 
哥们,我也碰到这个问题,删除这个架包没用啊,

#18


用MyEclipse自带的tomcat试试看,我以前遇到跟你一样的问题,就是那样解决的。

#19


兄弟,你解决问题了吗?我也是这个问题啊

#20


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml这怎么解决啊

#21