diff --git a/TapSchemaManager/src/main/webapp/expired.xhtml b/TapSchemaManager/src/main/webapp/expired.xhtml
index 88767cd934986eed0445dd6ed6b2115309c8b27b..141f91e071abf3427d476f9f42530baf2ce57978 100644
--- a/TapSchemaManager/src/main/webapp/expired.xhtml
+++ b/TapSchemaManager/src/main/webapp/expired.xhtml
@@ -4,7 +4,7 @@
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:ui="http://java.sun.com/jsf/facelets" >
-    <ui:define name="title">TapSchema Manager - Credentials insertion page</ui:define>
+    <ui:define name="title">TapSchema Manager - Session Expired</ui:define>
     <ui:define name="content">
         <br/>
         <div class="container">
diff --git a/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java b/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java
index b22b8c6ae7cbbb56976cb04541dd023ffe6b0061..2ab85ec098502e88644d6b3d53e1f704248e1f66 100644
--- a/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java
+++ b/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java
@@ -1,6 +1,8 @@
 package it.inaf.oats.ia2.tapschemamanager.datalayer;
 
 import java.io.Closeable;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.sql.Connection;
 import java.sql.SQLException;
@@ -67,10 +69,10 @@ class ColumnsInfo implements Serializable {
 }
 
 /**
- * This class manage load of TAP_SCHEMA entities and other database schemas informations.
- * IMPORTANT: If you use this class inside another object remember to call the 
- * close method to release the occupied resources.
- * 
+ * This class manage load of TAP_SCHEMA entities and other database schemas
+ * informations. IMPORTANT: If you use this class inside another object remember
+ * to call the close method to release the occupied resources.
+ *
  * @author Sonia Zorba <zorba at oats.inaf.it>
  */
 public class TapSchemaHandler implements Serializable, Closeable {
@@ -317,7 +319,7 @@ public class TapSchemaHandler implements Serializable, Closeable {
     public void save() throws SQLException {
         if (exists) {
             loadEntityManager();
-            
+
             entityManager.getTransaction().begin();
             for (SchemaEntity toRemoveSchema : toRemoveSchemas) {
                 entityManager.remove(toRemoveSchema);
@@ -334,7 +336,7 @@ public class TapSchemaHandler implements Serializable, Closeable {
             } finally {
                 closeConnection();
             }
-            
+
             loadEntityManager();
 
             entityManager.getTransaction().begin();
@@ -366,20 +368,38 @@ public class TapSchemaHandler implements Serializable, Closeable {
     }
 
     private void loadEntityManager() {
-        if(entityManager == null) {
+        if (entityManager == null) {
             entityManager = DataProvider.getEntityManager(credentials, name);
         }
     }
-    
+
     @Override
     public void close() {
-        EntityManagerFactory efFactory = entityManager.getEntityManagerFactory();
-        entityManager.close();
-        efFactory.close();
+        
+        if (entityManager.isOpen()) {
+            EntityManagerFactory efFactory = entityManager.getEntityManagerFactory();
+            
+            entityManager.close();
+            
+            if (efFactory.isOpen()) {
+                efFactory.close();
+            }
+        }
+
         try {
             closeConnection();
         } catch (SQLException e) {
             e.printStackTrace(System.err);
         }
     }
+
+    /**
+     * Automatic closing on serialization
+     * @param stream
+     * @throws IOException 
+     */
+    private void writeObject(ObjectOutputStream stream) throws IOException {
+        close();
+        stream.defaultWriteObject();
+    }
 }
diff --git a/TapSchemaManagerDL/src/test/java/TestQuery.java b/TapSchemaManagerDL/src/test/java/TestQuery.java
index 32c36ebda5e6c5ebbe41e92cfd06ec32e30f5177..c5f917d96bb4e80219ba5f74a3664e196e0a867e 100644
--- a/TapSchemaManagerDL/src/test/java/TestQuery.java
+++ b/TapSchemaManagerDL/src/test/java/TestQuery.java
@@ -7,6 +7,10 @@ import it.inaf.oats.ia2.tapschemamanager.datalayer.KeyEntity;
 import it.inaf.oats.ia2.tapschemamanager.datalayer.SchemaEntity;
 import it.inaf.oats.ia2.tapschemamanager.datalayer.TableEntity;
 import it.inaf.oats.ia2.tapschemamanager.datalayer.TapSchemaHandler;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -109,6 +113,28 @@ public class TestQuery {
         }
     }
 
+    @Test
+    public void testSerialization() throws Exception {
+        TapSchemaHandler tapSchemaHandler = new TapSchemaHandler(credentials, "vlkb_voinfo_schema", true);
+
+        System.out.println("schemas size = " + tapSchemaHandler.getSchemas().size());
+
+        FileOutputStream fileOut = new FileOutputStream("/home/sonia/test.ser");
+        ObjectOutputStream out = new ObjectOutputStream(fileOut);
+        out.writeObject(tapSchemaHandler);
+        out.close();
+        fileOut.close();
+
+        FileInputStream fileIn = new FileInputStream("/home/sonia/test.ser");
+        ObjectInputStream in = new ObjectInputStream(fileIn);
+        tapSchemaHandler = (TapSchemaHandler) in.readObject();
+        in.close();
+        fileIn.close();
+
+        tapSchemaHandler.save();
+        System.out.println("schemas size = " + tapSchemaHandler.getSchemas().size());
+    }
+
     @Ignore
     @Test
     public void loadSchema() throws SQLException {