4

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?

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
Mirco
  • 2,940
  • 5
  • 34
  • 57
  • Are you sure that `mysql-connector-bundle` bundle proper installed into container? – CAMOBAP Nov 08 '12 at 15:18
  • Yes, i used mysql-connector-java and it's marked as active. – Mirco Nov 08 '12 at 15:19
  • Do you seen those solutions http://stackoverflow.com/questions/5982675/sqlexception-no-suitable-driver-found? – CAMOBAP Nov 08 '12 at 15:30
  • Yes but they don't fit. Checked my hibernate-cfg twice, no mistakes in there. – Mirco Nov 08 '12 at 15:32
  • 2
    Please attach manifest for `mysql-connector-bundle` and your bundle that communicate with DB. – CAMOBAP Nov 08 '12 at 15:36
  • i think it depends how the mysql-connector-bundle is loading the driver. is it using the classloader then the bundle could be active, but there is no driver loaded at all or the more OSGi way to have an DataSourceFactory service (specified in OSGi E Spec 4.3). Unfortunality I do not know much about the bundle u r using but i would definitely have a look how the driver will be loaded as well – christian.vogel Nov 09 '12 at 09:59

2 Answers2

2

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?

Community
  • 1
  • 1
GeertPt
  • 16,398
  • 2
  • 37
  • 61
2

Hibernate can't access do data and classes from other bundles (at least in version 3.x; I don't know about version 4). It only works easily if all (methods using hibernate, pojos, mapping files, all libraries) is in the same bundle. It can't access resources in other bundles.

Please also see my answer in this thread.

Community
  • 1
  • 1
Johanna
  • 5,223
  • 1
  • 21
  • 38