You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/06/23 12:41:59 UTC
svn commit: r957151 -
/jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
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;
+ }
}
/**