严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through bean property 'eventListeners': : Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject配置如下:
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-autowire="byType">

<!-- 数据源  -->
<bean id="dataSource" 
class="org.apache.commons.dbcp.BasicDataSource" 
destroy-method="close">
   <property name="driverClassName">
        <value>com.mysql.jdbc.Driver</value>
   </property>
   <!-- 修改数据库用户名 密码 -->
   <property name="url" >
        <value>jdbc:mysql://localhost:3306/ssh</value>
   </property>
  
   <property name="username">
       <value>root</value>
   </property>
  
   <property name="password">
       <value>521239</value>
   </property>
  
  </bean>
 
 <bean id="sessionFactory" class=
      "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
         <ref local="dataSource"/>  
      </property>
      <property name="mappingResources">
         <list>
               <value>com/bean/User.hbm.xml</value>
         </list>
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">
               org.hibernate.dialect.MySQLDialect
            </prop>
            <prop key="hibernate.show_sql">
               true
            </prop>
         </props>
      </property>
   </bean>
 
 
<!-- dao -->
    <bean id="userDao" class="com.dao.impl.UserDAOImpl" scope="singleton">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- service -->
<bean id="userService" class="com.service.impl.UserServiceImpl" scope="singleton">
    <property name="userDao" >
       <ref local="userDao"/>
     </property>
 </bean>
 
 <bean id="userAction" class="com.action.user.UserAction" scope="prototype">
   <property name="service" ref="userService"></property>
 </bean>
</beans>

解决方案 »

  1.   

    <property name="dataSource" ref="dataSource"/>
      

  2.   

    是不是SSH整合呀是的话 看看你的web.xml 和 struts-config.xml的配置对不对
      

  3.   

    rg.springframework.web.context.ContextLoaderListener
    web.xml是不是没配置东西,
      

  4.   

    web.xml
    <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>
       /WEB-INF/classes/applicationContext*.xml
       classpath:applicationContext*.xml
       </param-value>
      </context-param>
      <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      

  5.   

    org.springframework.web.context.ContextLoaderListener监听器配置好了没?
      

  6.   

    很明显的要在、web.xml中添加一个spring初始化监听。
    参考: <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> /WEB-INF/configs/applicationContext*.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
      

  7.   

    有两种情况:(1)你的sessionFactory有问题配置可能没有连接到数据库。可以写一个main 方法来测试一下这个
    对象是否为null.
    (2)你的userDAO这个类(或者父类)可能没有继承HibernateDaoSupport;
      

  8.   

    那个我在网上看到有大虾说使用同一ip的电脑过多可能造成数据库连接不上,请问有这么个情况么?我在小区里面,和别人共用一个ip