=== modified file 'src/com/goldencode/p2j/admin/AdminServerImpl.java'
--- old/src/com/goldencode/p2j/admin/AdminServerImpl.java	2025-04-03 18:47:13 +0000
+++ new/src/com/goldencode/p2j/admin/AdminServerImpl.java	2025-07-10 18:59:40 +0000
@@ -300,32 +300,37 @@
     */
    public static int setTargetLive(boolean stayCurrent, boolean databaseAutoConnect, boolean restCall)
    {
-      WorkArea wa = workArea.get();
-      if (restCall && wa.initialized)
-      {
-         return 0;
-      }
-      
-      if (databaseAutoConnect)
-      {
-         DatabaseManager.autoConnect();
-      }
-      
-      // mark session as targeted
-      wa.targeted = true;
-      wa.stayCurrent = stayCurrent;
-      
-      // bind session to the directory service
-      wa.ds = DirectoryService.getInstance();
-      if (wa.ds.bind())
-      {
-         wa.bound = true;
-      }
-      
-      wa.sa = new SecurityAdmin(wa.ds);
-      wa.initialized = true;
-      
-      return sm.adminGetCacheSerial(wa.stayCurrent);
+      try
+      {
+         WorkArea wa = workArea.get();
+         if (restCall && wa.initialized)
+         {
+            return 0;
+         }
+         
+         // mark session as targeted
+         wa.targeted = true;
+         wa.stayCurrent = stayCurrent;
+         
+         // bind session to the directory service
+         wa.ds = DirectoryService.getInstance();
+         if (wa.ds.bind())
+         {
+            wa.bound = true;
+         }
+         
+         wa.sa = new SecurityAdmin(wa.ds);
+         wa.initialized = true;
+         
+         return sm.adminGetCacheSerial(wa.stayCurrent);
+      }
+      finally
+      {
+         if (databaseAutoConnect)
+         {
+            DatabaseManager.autoConnect();
+         }
+      }
    }
    
    /**

