Details
Description
Steps to reproduce
- Compile or get a karaf-3.0.0-SNAPSHOT and unpack it
- Install openjpa-2.2.0 (using the attached feature-file)
- Deploy a bundle containing a persistence-unit (attached jar for example)
get the following Exception 4 times:
ERROR: Bundle org.apache.aries.jpa.container [78] EventDispatcher: Error during dispatch. (java.lang.IllegalStateException: Unable to create persistence units for the bundle test.jpa.test.jpa.bundle/0.1.0.SNAPSHOT as previous persistence units already exist.) java.lang.IllegalStateException: Unable to create persistence units for the bundle test.jpa.test.jpa.bundle/0.1.0.SNAPSHOT as previous persistence units already exist.
See attachment for full stacktrace
In subsequent startups the Exception is still thrown but the stacktrace does not show in the console or the log.
Also when using equinox the Stacktrace does not appear in either the console or the log ever, but it's still thrown.
The problem is that the PersistenceBundleManager#addingBundle is called multiple times for the newly installed bundle.
The PersistenceBundleManager is passed as a BundleTrackerCustomizer to a BundleHookBundleTracker.
The BundleHookBundleTracker stores it in it's own private attribute and also passes it to it's super-constructor.
So the customizer is stored in the instance twice.
It's called by both BundleTracker$Tracked.customizerAdding and BundleHookBundleTracker$Tracked.customizerAdding.
Both "Tracked" recognize the bundle as untracked and call the addingBundle-method.