Hi Oleksandr,
Thanks for your reply. In answer to your question, I had set up my Spring configuration to have 2 session factories, each with it's own datasource, each with it's own transaction manager, and each with it's own transaction 'advice'. When I run the app., the first session factory produces a current session, and I can perform queries successfully with it. The second session factory throws the following error when I attempt to get a current session from it:
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
Here are a few logs from the point where I'm trying to get the current session from the second session factory:
2008-06-12 12:00:56,525 DEBUG [org.springframework.orm.hibernate3.SessionFactoryU tils] Opening Hibernate Session
2008-06-12 12:00:56,525 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4969621325926400
2008-06-12 12:00:56,525 DEBUG [org.springframework.orm.hibernate3.SessionFactoryU tils] Closing Hibernate Session
2008-06-12 12:00:56,525 ERROR [gov.nih.nci.cma.util.ApplicationContext] Caught error in ApplicationContext init method
2008-06-12 12:00:56,525 ERROR [gov.nih.nci.cma.util.ApplicationContext] org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
- here is the configuration that I have:
HTML Code:
<bean id="sessionFactory1"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>/WEB-INF/domain1-hibernate.cfg.xml</value>
</property>
</bean>
<bean id="sessionFactory2"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>/WEB-INF/domain2-hibernate.cfg.xml</value>
</property>
</bean>
<bean id="txManager1"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory1" />
</bean>
<bean id="txManager2"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory2" />
</bean>
<tx:advice id="txAdvice1" transaction-manager="txManager1">
<tx:attributes>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<tx:advice id="txAdvice2" transaction-manager="txManager2">
<tx:attributes>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
What do you think might be the problem? In the two Hibernate config files that I have, each has the following property defined:
<property name="current_session_context_class">thread</property>
Thanks for any help that you can give!