Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Hibernate SessionFactory as osgi:service (I have some problems with it...)
Hibernate SessionFactory as osgi:service [message #954965] Tue, 23 October 2012 07:49 Go to previous message
Alexander Kosarev is currently offline Alexander Kosarev
Messages: 3
Registered: October 2012
Junior Member
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
 
Read Message
Read Message
Read Message
Read Message
Previous Topic:How can I use JPA 2.0 with hibernate under virgo
Next Topic:Completeness of scoped plans
Goto Forum:
  


Current Time: Thu May 23 09:30:35 EDT 2013

Powered by FUDForum. Page generated in 0.09391 seconds