users@glassfish.java.net

[gf-users] Conrtainer managed entity managers on Glassfish/OSGI

From: Erik Brakkee <erik.brakkee_at_gmail.com>
Date: Wed, 21 Sep 2016 17:10:36 +0200

Hi,


I am porting an application to Glassfish that uses JPA. In particular,
there is one bundle containing a JPA persistence unit (and all entities)
and there is a WAR module that depends on the JPA module.

Now, reading in the "OSGI Application Development using Glassfish Server"
it seems that the only supported method is through application-managed
entity managers. In particular, I have tried injecting the EntityManager in
a servlet class of the WAR using @PersistenceContext but this fails.

One option that could work is to use Enterprise JPA from Apache Aries.
Another option would be use an application managed entity manager and
manage integration with transaction management myself.

What would be the recommended way to do this integration? In any case,
dynamic deployment of different bundles is not an issue. The application
server will always be started with all our bundles installed.

Cheers
  Erik