I got the following situation.
I'm using Apache Felix
as OSGi Service implementation and Apache Karaf
as OSGi container.
There is a bundle in karaf
which should save some data via hibernate into a database, but I always get a SQLException: No Suitable Driver found.
I deployed the mysql-connector-bundle
to karaf
.
The problem is, in my mind, that hibernate whether imports the mysql-driver-packages
nor my classes which should be mapped.
But I don't know hot to fix this. I'm familar to eclipse rcp where the buddy-policy fixes such problems, is there any best practice for this problem for felix
and karaf
?
What version of hibernate do you use? Only since Hibernate 4, hibernate is aware of OSGi classloaders, and it still doesn't have complete OSGi support. See e.g. https://hibernate.onjira.com/browse/HHH-7527, which is planned for Hibernate 4.2.
We used Gemini JPA with eclipselink instead as JPA provider in OSGi.
In the karaf eco-system, there is Aries JPA, which is primarly used with OpenJPA. See Which JPA providers are supported by Apache Aries Managed JPA?