Hello.
Sorry if I was not precise enough...
First about the OSGi environment : our ServiceMix in version 4.5.3 and its Karaf 2.2.11 provide an older version of the framework package (1.5.0), while the hibernate-osgi manifest requires :
Code:
org.osgi.framework;version="[1.6,2)",org.osgi.framework.wiring;version="[1.0,2)"
An import for "wiring" is also set, but it seems that this version of Karaf comes with none.
Then, about Aries, as all my attempts to add an alternative packaging of several bundles finally only led to conflicts, I decided to let my tests on this version of ServiceMix for a moment, even if ultimately we'll have to come back latter since our customer's current platform relies on the older version, and evaluate the situation with a newer version (5.0.1), and come back to test the old Karaf only if I manage to execute controled versions of bith Hibernate and my own test bundles.
This late version of ServiceMix comes with several prepackaged Hibernate 3.3.2, 4.2.7 and 4.3.1. This Karaf also provide more recent version of Aries packages, among others, the JPA container comes in version 1.0.0 instead of the 0.3. Before anything, I've tested my bundles with the 4.2.7, as our code targets JPA 2.0 and all my JUnit tests are done with 4.2.12. But the same errors occured when the entity manager factrory is about to be created and injected in my DAO service.
Code:
waiting for dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=MY-HIBERNATE-TESTS))(objectClass=javax.persistence.EntityManagerFactory))]
I've found on the Karaf forum a post about same kind of errors, and an explanation about it (
http://karaf.922171.n3.nabble.com/JPA-with-Karaf-td4031000.html). The problem seem to be in relation with the lifecycle of the bundles, something between the JPA continer, the Hibernate OSGi module and the DAO bundle itself.
A suggested workaround is to stop the Hibernate OSGi bundle, install our budles and restart Hiberanate's one. Changing the start level of the Hibernate OSGi module to make it start after all others is a possibility, and I've tested it with my own 4.2.12 feature.
This operation seems to work once, but any update of the DAO bundle leads the system to be instable, and a stop/start of the OSGi bundle is not always effective. Generally, rebooting ServiceMix reset the bundle start order and the entity manager after all is injected !
But transactions don't work, and write operations are not commited to the database. My service level bundle declares transactions requirement, but it seems that the entity manager is not actually managed and transactions are not propagated.
Code:
<bean
id="my.business"
class="my.tests.hibernate.business.service.BusinessService">
<property name="dao">
<reference interface="my.tests.hibernate.dao.SuperDAO" />
</property>
<tx:transaction
method="*"
value="Required" />
</bean>
<service
ref="my.business"
interface="my.tests.hibernate.business.Business" />
The DAO level bundle blueprint that exposes the persistence is the following :
Code:
<bean
id="my.dao"
class="my.tests.hibernate.dao.jpa.JpaSuperDAO">
<jpa:context
property="entityManager"
unitname="MY-HIBERNATE-TESTS">
<jpa:map>
<entry
key="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect" />
<entry
key="hibernate.show_sql"
value="true" />
</jpa:map>
</jpa:context>
</bean>
<service
ref="my.dao"
interface="my.tests.hibernate.dao.SuperDAO" />
Though, in my Hibernate feature, I activate the JPA and transaction features.
So, "bit by bit" I'm finally on a more optimistic perspective to find a solution, but it seems that anyway there is always a new concern...
Any idea about the transaction problem ?
Thanks for you help.
Regards.