Fast Object Database for Java - with JPA/JDO support

javax.persistence.PersistenceException: No Persistence provider for EntityManager named in Karaf 4.0.7 and OSGi DS test



I've written a small OSGi Declarative Services application to run in Apache Karaf 4.0.7 to persist an entity into an ObjectDB database.

I'm working in C/S model and I have both the ObjectDB server and Karaf running on localhost.

When I try to persist the entity I'm getting the 

javax.persistence.PersistenceException: No Persistence provider for EntityManager named objectdb://localhost:6136/technolink.odb;user=admin;password=admin

exception in the Karaf log.

I have deployed the objectdb.jar file that I fixed in order to make it a valid OSGi bundle.

I have attached:

1) my bundle to deploy to Karaf

2) the objectdb bundle I use

3) a zip file containing the source project (Eclipse Neon.1, Bndtools 3.3.0).

In order to build the code, you need to have lombok in the classpath ( and lombok enabled in Eclipse (

I saw a thread in the forum (form 2011 - that refers to the same exception and the workaround is to change the classloader. I suppose in that case, the objectdb.jar file was included in the bundle that is supposed to reference it.

I want to deploy objectdb.jar file only once to my karaf and use it like any other OSGi bundle.

Many thanks in advance for your precious feedback,



application/java-archive icon objectdb_0.jar (1.42 MB)
objectdb bundle that I fixed

BTW: I forgot to mention that if I set the classloader in the @Activate method:

oldClassLoader = Thread.currentThread().getContextClassLoader();

then it works.




This error message is produced by JPA if it cannot find an appropriate JPA implementation in the classpath. You must make sure that ObjectDB is available in the context class loader. Setting the context class loader, as suggested in #2 above, is a known solution.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)


thank you for confirming that changing the class path is the right way to go. At least I'm not missing something really obvious then.

Are you planning to improve OSGi support in order to support e.g. Declarative Services and possibly provide EntityManagerFactory as a service such that one simply needs to request a reference to the service?

Would be nice if one could simply drop the objectdb bundle into the runtime, request a reference to the Factory and not having to worry about where it is coming from.




This is possible, but we prefer to avoid introducing our own API, so possibly this can be achieved if a future version of JPA will define a standard API for OSGi integration.


ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)


OK, sounds like a plan.



Post Reply