jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r957151 - /jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
Date Wed, 23 Jun 2010 10:41:59 GMT
Author: jukka
Date: Wed Jun 23 10:41:58 2010
New Revision: 957151

URL: http://svn.apache.org/viewvc?rev=957151&view=rev
Log:
JCR-1457: Restart of RMI-component fails (because it's not released while shutdown)

Explicitly unexport both the RMI repository and the RMI registry

Modified:
    jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java?rev=957151&r1=957150&r2=957151&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
Wed Jun 23 10:41:58 2010
@@ -37,11 +37,14 @@ import java.net.ServerSocket;
 import java.net.UnknownHostException;
 import java.rmi.AlreadyBoundException;
 import java.rmi.Naming;
+import java.rmi.NoSuchObjectException;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
 import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.NoSuchElementException;
 import java.util.Properties;
 
 import javax.jcr.Repository;
@@ -170,6 +173,8 @@ public class RepositoryStartupServlet ex
      */
     private InitialContext jndiContext;
 
+    private Registry rmiRegistry = null;
+
     /**
      * Keeps a strong reference to the server side RMI repository instance to
      * prevent the RMI distributed Garbage Collector from collecting the
@@ -524,7 +529,7 @@ public class RepositoryStartupServlet ex
                 // and the server socket factory retrieved above. This also
                 // binds to the server socket to the rmiHost:rmiPort.
                 reg = LocateRegistry.createRegistry(rc.rmiPort(), null, sf);
-
+                rmiRegistry = reg;
             } catch (UnknownHostException uhe) {
                 // thrown if the rmiHost cannot be resolved into an IP-Address
                 // by getRMIServerSocketFactory
@@ -579,7 +584,13 @@ public class RepositoryStartupServlet ex
      */
     private void unregisterRMI() {
         if (rmiRepository != null) {
-            // drop strong referenece to remote repository
+            // Forcibly unexport the repository;
+            try {
+                UnicastRemoteObject.unexportObject(rmiRepository, true);
+            } catch (NoSuchObjectException e) {
+                log.warn("Odd, the RMI repository was not exported", e);
+            }
+            // drop strong reference to remote repository
             rmiRepository = null;
 
             // unregister repository
@@ -589,6 +600,15 @@ public class RepositoryStartupServlet ex
                 log("Error while unbinding repository from JNDI: " + e);
             }
         }
+
+        if (rmiRegistry != null) {
+            try {
+                UnicastRemoteObject.unexportObject(rmiRegistry, true);
+            } catch (NoSuchObjectException e) {
+                log.warn("Odd, the RMI registry was not exported", e);
+            }
+            rmiRegistry = null;
+        }
     }
 
     /**



Mime
View raw message