Hi all! I develop a project containing 2 bundles. In first bundle I described session factory and transaction manager and publish them as osgi services:
<bean class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" id="sessionFactory">
<property name="dataSource" ref="dataSource"/>
...
</bean>
<bean class="org.springframework.orm.hibernate4.HibernateTransactionManager" id="transactionManager"
p:sessionFactory-ref="sessionFactory"/>
<osgi:service id="sessionFactoryService" ref="sessionFactory" interface="org.hibernate.SessionFactory"/>
<osgi:service id="transactionManagerService" ref="transactionManager" interface="org.springframework.transaction.PlatformTransactionManager"/>
In second bundle I described references to these services:
<osgi:reference id="sessionFactory" bean-name="sessionFactory" interface="org.hibernate.SessionFactory"/>
<osgi:reference id="transactionManager" bean-name="transactionManager" interface="org.springframework.transaction.PlatformTransactionManager"/>
Contexts of both bundles have
<tx:annotation-driven transaction-manager="transactionManager"/>
I don't have any problems if I try to open new session and to use it. But if I try to get current session in second bundle (in first bundle it works fine), I get an error message:
Caused by: org.hibernate.HibernateException: No Session found for current thread
at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)
...
Is it real to work with session opened in another bundle?
Spring Framework version is 3.1.2, Hibernate - 4.1.7