日期:2014-05-17  浏览次数:20837 次

各位大哥,帮我检查一下配置哪里配错了
自己做ssh框架,报了下面的错,在网上找了很多资料,但还是没有解决,各位大哥,帮忙看下
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

下面是我的配置文件,第一个applicationContext.xml
<?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.5.xsd">

<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&amp;characterEncoding=utf-8</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>123</value>
</property>
</bean>

<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- 格式化输出sql语句 -->
  <prop key="hibernate.format_sql">true</prop>
  <prop key="hibernate.generate_statistics">true</prop>
</props>
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/ourcompany/dao/pojo</value>
</list>
</property>
</bean>

<!-- 配置transactionFactory -->
<bean id="transactionFactory" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!-- 配置事务代理 -->
<bean id="transactionproxy" lazy-init="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionFactory" />
<property name="transactionAttributes">
<props>
<prop key="set*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="get*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="save*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="validateUser*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="remove*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="delete*">PROPAGATION_REQUIRED,-DataAccessException</prop>
</props>
</property>
</bean>

</beans>
-----------------------------------------------------------
第二个applicationContext-action.xml
<?xml version="1.0" encoding="UTF-8"?>
<