Search code examples
osgiopenjpaapache-karafosgi-bundle

How to create the JPA OSGI bundle


I want to create the OSGI persistence service bundle with JPA 2.0. I am using OpenJpa as a persistence provider.

I tried a sample OSGI bundle with JPA support and I faced the problem when my client call the persistence functionality. The service couldnt create the EntityManagerFactory. Always it is null.

I am using Apache Karaf as the platform to install the services.

Currently I am creating a OSGI bundle in eclipse and export it as a bundle and deploy it in Karaf. The client can call the service. But the issue is when I get EntityManagerFactory.

I am using bellow code to get EntityManagerFactory.

  OpenJPAEntityManagerFactory emf = OpenJPAPersistence.createEntityManagerFactory
    ("StudentServiceProvider","META-INF/persistence.xml");

Please provide me a clear idea how can I create the OSGI persitence bundle with OpenJPA.


Solution

  • You can take a look at my tutorial for JPA on OSGi using Apache Aries like Holly recommends.