[ 
https://issues.apache.org/jira/browse/ARIES-1162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14194743#comment-14194743
 ] 

Christian Schneider commented on ARIES-1162:
--------------------------------------------

Applied the patch with a small change of not calling setupManager:

diff --git 
a/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
 
b/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
index 1334f6e..6bf4497 100644
--- 
a/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
+++ 
b/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
@@ -284,11 +284,16 @@
     EntityManagerFactoryManager mgr = (EntityManagerFactoryManager) object;
     //If the bundle was updated we need to destroy it and re-initialize
     //the EntityManagerFactoryManager
-    if(event != null && event.getType() == BundleEvent.UPDATED) {
+    //If the bundle becomes unresolved we need to destroy persistenceUnits, 
since they
+    //keep a reference to bundle classloader which has wiring m_isDisposed set 
to true
+    //this occurs when Karaf BundleWatcher is used.
+    if(event != null && (event.getType() == BundleEvent.UPDATED || 
event.getType() == BundleEvent.UNRESOLVED)) {
       mgr.destroy();
       persistenceUnitFactory.destroyPersistenceBundle(ctx, bundle);
-      //Don't add to the managersAwaitingProviders, the setupManager will do it
-      setupManager(bundle, mgr, true);
+      if (event.getType() == BundleEvent.UPDATED) {
+          //Don't add to the managersAwaitingProviders, the setupManager will 
do it
+          setupManager(bundle, mgr, true);
+      }
     } else {
       try {
         boolean reassign;

> Persistence Units neet to be destroyed when bundle becomes unresolved 
> ----------------------------------------------------------------------
>
>                 Key: ARIES-1162
>                 URL: https://issues.apache.org/jira/browse/ARIES-1162
>             Project: Aries
>          Issue Type: Bug
>          Components: JPA
>            Reporter: Konstantin Pelykh
>         Attachments: persistentUnits_are_not_destroyed.patch
>
>
> This problem occurs when BundleWatcher is used. 
> When bundle is updated, its wiring becomes disposed, and UNRESOLVED event is 
> fired. PersistenceBundleManager needs to remove associated persistence units.
> patch is attached



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to