Spring 春季及;休眠:无法绑定会话。

Spring 春季及;休眠:无法绑定会话。,spring,hibernate,spring-transactions,Spring,Hibernate,Spring Transactions,在生产过程中,我们会遇到下一个错误: 2013-04-18 20:47:50,199 http-0.0.0.0-8443-35 ERROR [Jersey Web Application]] [userId: 57916] Servlet.service() for servlet Jersey Web Application threw exception java.lang.IllegalStateException: Already value [org.springframework.o

在生产过程中,我们会遇到下一个错误:

2013-04-18 20:47:50,199 http-0.0.0.0-8443-35 ERROR [Jersey Web Application]] [userId: 57916] Servlet.service() for servlet Jersey Web Application threw exception
java.lang.IllegalStateException: Already value [org.springframework.orm.hibernate3.SessionHolder@4cccafeb] for key [org.hibernate.impl.SessionFactoryImpl@1457e272] bound to thread [http-0.0.0.0-8443-35]
    at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:189)       
我们为每个完整服务请求的开放会话设置了Hibernate会话筛选器

com.mycompany.SessionPerRequestHelper {
    public static Session openSession() {
        SessionFactory sessionFactory = getSessionFactory();

        Session sess = sessionFactory.openSession();
        sessThreadLocal.set(sess);

        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(sess));
        TransactionSynchronizationManager.initSynchronization();

        return sess;
    }
}
休眠上下文配置:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:com/transportexchangegroup/domain/hibernate.cfg.xml" />
        <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

和hibernate.cfg

<hibernate-configuration>
    <session-factory>
        <property name="dialect">org.hibernatespatial.postgis.PostgisDialect</property>
        <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
        <property name="current_session_context_class">thread</property>
    </session-factory>
</hibernate-configuration>

org.hibernatespatial.postgis.postgisdial
org.hibernate.transaction.jdbc事务工厂
线
最好使用而不是您的
SessionPerRequestHelper