Index: src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java	(revision 539491)
+++ src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java	(working copy)
@@ -196,6 +196,11 @@
     private FileLock repLock;
 
     /**
+     * unique repository instance id (canonicalized internalized path of home directory)
+     */
+    private String repId;
+
+    /**
      * Clustered node used, <code>null</code> if clustering is not configured.
      */
     private ClusterNode clusterNode;
@@ -429,6 +434,35 @@
                     + " appears to be in use since the file at "
                     + lock.getAbsolutePath() + " is locked by another process.");
         }
+
+        // JCR-933: due to a bug in java 1.4/1.5 on *nix platforms
+        // it's possible that java.nio.channels.FileChannel.tryLock()
+        // returns a non-null FileLock object although the lock is already
+        // held by *this* jvm process
+        try {
+            repId = home.getCanonicalPath().intern();
+            synchronized (repId) {
+                if (null != System.getProperty(repId)) {
+                    // note that the newly acquired (redundant) file lock
+                    // is deliberately *not* released because this could
+                    // potentially cause, depending on the implementation,
+                    // the previously acquired lock(s) to be released
+                    // as well
+                    throw new RepositoryException(
+                            "The repository home at " + home.getAbsolutePath()
+                            + " appears to be already locked by the current process.");
+                } else {
+                    try {
+                        System.setProperty(repId, repId);
+                    } catch (SecurityException e) {
+                        log.warn("Unable to set system property: " + e.getMessage());
+                    }
+                }
+            }
+        } catch (IOException e) {
+            throw new RepositoryException(
+                "Unable to determine canonical path of " + home.getAbsolutePath(), e);
+        }
     }
 
     /**
@@ -451,6 +485,17 @@
         if (!lock.delete()) {
             log.error("Unable to release repository lock");
         }
+
+        // JCR-933: see #acquireRepositoryLock()
+        if (repId != null) {
+            synchronized (repId) {
+                try {
+                    System.getProperties().remove(repId);
+                } catch (SecurityException e) {
+                    log.error("Unable to clear system property: " + e.getMessage());
+                }
+            }
+        }
     }
 
     /**
