Index: src/main/java/com/xpn/xwiki/store/CachedXWikiDocument.java
===================================================================
--- src/main/java/com/xpn/xwiki/store/CachedXWikiDocument.java	(revision 0)
+++ src/main/java/com/xpn/xwiki/store/CachedXWikiDocument.java	(revision 0)
@@ -0,0 +1,68 @@
+
+package com.xpn.xwiki.store;
+
+import com.xpn.xwiki.doc.XWikiDocument;
+import java.io.*;
+
+public class CachedXWikiDocument implements Serializable 
+{
+  protected XWikiDocument doc;
+
+  protected String version;
+
+  public CachedXWikiDocument() {
+    this.doc = null;
+    this.version = null;
+  }
+
+  public CachedXWikiDocument(XWikiDocument doc) {
+    this.doc = doc;
+    if (this.doc!=null)
+     this.version = doc.getVersion();
+  }
+
+  public XWikiDocument getXWikiDocument() {
+    return doc;
+  } 
+
+  public void setXWikiDocument(XWikiDocument doc) {
+    this.doc = doc;
+  }
+
+  public String getVersion() {
+    return this.version;
+  } 
+
+  public void setVersion(String version) {
+    this.version = version;
+  } 
+
+  public boolean equals(Object c1) {
+    if (c1==null)
+     return false;
+ 
+    String version = ((XWikiDocument)c1).getVersion();
+    if (this.version==null && version==null)
+     return true;
+
+    if (this.version==null || version==null)
+     return false;
+
+    return this.version.equals(version);
+  }
+
+   /*
+       Special serialize and unserialize to make it for for JBoss cache cluster
+    */
+    private void writeObject(java.io.ObjectOutputStream out) throws IOException
+    {
+      out.writeObject(getVersion());
+    }
+
+    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
+    {
+      String version = (String) in.readObject();
+      setVersion(version);
+      this.doc = null;
+    }
+}
Index: src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java
===================================================================
--- src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java	(revision 18017)
+++ src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java	(working copy)
@@ -50,7 +50,7 @@
 
     private XWikiStoreInterface store;
 
-    private Cache<XWikiDocument> cache;
+    private Cache<CachedXWikiDocument> cache;
 
     private Cache<Boolean> pageExistCache;
 
@@ -96,7 +96,7 @@
             lru.setMaxEntries(capacity);
             cacheConfiguration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
 
-            Cache<XWikiDocument> pageCache = cacheFactory.newCache(cacheConfiguration);
+            Cache<CachedXWikiDocument> pageCache = cacheFactory.newCache(cacheConfiguration);
             setCache(pageCache);
 
             cacheConfiguration = new CacheConfiguration();
@@ -140,7 +140,7 @@
             // We need to flush so that caches
             // on the cluster are informed about the change
             getCache().remove(key);
-            getCache().set(key, doc);
+            getCache().set(key, new CachedXWikiDocument(doc));
             getPageExistCache().remove(key);
             getPageExistCache().set(key, new Boolean(true));
         }
@@ -192,10 +192,10 @@
                 log.debug("Cache: Trying to get doc " + key + " from cache");
             }
 
-            XWikiDocument cachedoc = getCache().get(key);
+            CachedXWikiDocument cachedoc = getCache().get(key);
 
-            if (cachedoc != null) {
-                doc = cachedoc;
+            if ((cachedoc != null)&&(cachedoc.getXWikiDocument()!=null)) {
+                doc = cachedoc.getXWikiDocument();
                 doc.setFromCache(true);
 
                 if (log.isDebugEnabled()) {
@@ -214,7 +214,7 @@
                     log.debug("Cache: put doc " + key + " in cache");
                 }
 
-                getCache().set(key, doc);
+                getCache().set(key, new CachedXWikiDocument(doc));
                 getPageExistCache().set(key, new Boolean(!doc.isNew()));
             }
         }
@@ -599,12 +599,12 @@
         }
     }
 
-    public Cache<XWikiDocument> getCache()
+    public Cache<CachedXWikiDocument> getCache()
     {
         return this.cache;
     }
 
-    public void setCache(Cache<XWikiDocument> cache)
+    public void setCache(Cache<CachedXWikiDocument> cache)
     {
         this.cache = cache;
     }
