Search code examples
osgiopenjpaosgi-bundlepersistence.xmlopenjpa-maven-plugin

Runtime Enhancement in OSGi environment using code


Problem : 1. JPA Classes/entities are in Bundle 1 and Bundle 2 using same persistence unit 2. Bundle 3 is trying to access(wrapper APIs for DB API abstraction) the classes in Bundle 1 and Bundle 2. 3. Runtime enhancement is not working.

So what I am planning to do is to enhance the JPA entities using Code, where in just before the bundle 3 comes up, these entities in Bundle 1 could be enhanced. I am planning doing this as the runtime enhancement does not complete and the bundle 3 comes up . This leads to DB APIs(Bundle 3 APIs) failure as tables are not created.


Solution

  • We had the same problem in a former project with openjpa and OSGi. Luckily, OpenJPA supports compile time enhancement which could be done via the openjpa maven plugin as described here: http://openjpa.apache.org/enhancement-with-maven.html

    And there is also an eclipse maven connector which supports runtime-enhancement inside the IDE, which is really comfortable if you want to use remote deployment. http://openjpa-maven-connector.googlecode.com/svn/trunk/