OSGi and Hibernate - not suitable for the driver

I have the following situation. I use Apache Felix as an implementation of OSGi Service and Apache Karaf as an OSGi container. There is a package in karaf that should save some data through hibernation to the database, but I always get SQLException: No Suitable Driver found. I deployed mysql-connector-bundle to karaf . The problem is, in my opinion, in sleep mode: does mysql-driver-packages and my classes import which should be mapped. But I do not know how to fix it. I am familiar with eclipse rcp where a buddy policy fixes such problems, is there any best practice for this problem for felix and karaf ?

+4
source share
2 answers

What version of sleep mode are you using? Only with Hibernate 4, hibernate is aware of OSGi class loaders, and it still does not have full OSGi support. See https://hibernate.onjira.com/browse/HHH-7527 , which is planned for Hibernate 4.2.

We used Gemini JPA instead of eclipselink instead of JPA provider in OSGi.

There is a JPA Aries in the karaf ecosystem, which is used initially with OpenJPA. See Which JPA Providers are Supported by Apache Aries Managed JPA?

+2
source

Hibernate cannot access data and classes from other packages (at least in version 3.x, I don't know about version 4). It works only if all (methods using hibernate, pojos, mapping files, all libraries) are in one set. It cannot access resources in other packages.

Also see my answer in this section .

+2
source

Source: https://habr.com/ru/post/1444837/


All Articles