debugging possible ClassCastException on old kiwi databases
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
index cfb1637..25e6e3c 100644
--- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/LiteralCommons.java
@@ -40,7 +40,6 @@
 
     private static final int HASH_BITS=128;
 
-
     private static DatatypeFactory dtf;
     static {
         try {
@@ -50,7 +49,6 @@
         }
     }
 
-    
     /**
 	 * Create a cache key for a literal with the given content, locale and type
 	 *
@@ -75,8 +73,6 @@
         return createCacheKey(content, language != null ? language.getLanguage() : null, type);
     }
 
-
-
     /**
      * Create a cache key for the date literal with the given date. Converts the date
      * to a XMLGregorianCalendar with UTC timezone and then calls the method above.
@@ -162,4 +158,5 @@
     private LiteralCommons() {
         // static access only
     }
+
 }
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
index 7e5c448..ae65ea3 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiNode.java
@@ -34,9 +34,6 @@
  */
 public abstract class KiWiNode implements Value, Serializable {
 
-    /**
-     *
-     */
     private static final long serialVersionUID = 4652575123005436645L;
 
     /**
@@ -45,13 +42,11 @@
      */
     private long id = -1L;
 
-
     /**
      * The creation date of the KiWiNode.
      **/
     private Date created;
 
-
     protected KiWiNode() {
         this(new Date());
     }
@@ -60,7 +55,6 @@
         this.created   = created;
     }
 
-
     /**
      * Return the database ID of this node. Can be used to refer to the node in the context of one triple store
      * instance, but should not be exposed outside.
@@ -71,7 +65,6 @@
         return id;
     }
 
-
     /**
      * Update the database id of the node.
      *
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
index dba0c0e..650892d 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
@@ -79,13 +79,11 @@
      */
     private Map<Long,KiWiTriple> tripleCache;
 
-
     /**
      * Cache URI resources by uri
      */
     private Map<String,KiWiUriResource> uriCache;
 
-
     /**
      * Cache BNodes by BNode ID
      */
@@ -96,7 +94,6 @@
      */
     private Map<String,KiWiLiteral> literalCache;
 
-
     /**
      * Look up namespaces by URI
      */
@@ -131,7 +128,6 @@
     private ReentrantLock uriLock;
     private ReentrantLock bnodeLock;
 
-
     // this set keeps track of all statements that have been deleted in the active transaction of this connection
     // this is needed to be able to determine if adding the triple again will merely undo a deletion or is a
     // completely new addition to the triple store
@@ -604,7 +600,6 @@
         }
     }
 
-
     /**
      * Load a KiWiAnonResource by anonymous ID. The method will first look in the node cache for
      * cached nodes. If no cache entry is found, it will run a database query ('load.bnode_by_anonid')
@@ -626,7 +621,6 @@
 
         requireJDBCConnection();
 
-
         bnodeLock.lock();
 
         try {
@@ -844,7 +838,7 @@
      */
     public KiWiDoubleLiteral loadLiteral(double value) throws SQLException {
         // look in cache
-        KiWiLiteral element = literalCache.get(LiteralCommons.createCacheKey(Double.toString(value),(String)null,Namespaces.NS_XSD + "double"));
+        KiWiLiteral element = literalCache.get(LiteralCommons.createCacheKey(Double.toString(value), (String)null,Namespaces.NS_XSD + "double"));
         if(element != null && element instanceof KiWiDoubleLiteral) {
             return (KiWiDoubleLiteral)element;
         }
@@ -864,17 +858,21 @@
             // otherwise prepare a query, depending on the parameters given
             PreparedStatement query = getPreparedStatement("load.literal_by_dv");
             query.setDouble(1, value);
-            query.setLong(2,ltype.getId());
+            query.setLong(2, ltype.getId());
 
             // run the database query and if it yields a result, construct a new node; the method call will take care of
             // caching the constructed node for future calls
             ResultSet result = query.executeQuery();
+            KiWiNode kiWiNode = null;
             try {
-                if(result.next()) {
-                    return (KiWiDoubleLiteral)constructNodeFromDatabase(result);
+                if (result.next()) {
+                    return (KiWiDoubleLiteral) constructNodeFromDatabase(result);
                 } else {
                     return null;
                 }
+            } catch (RuntimeException e) {
+                log.error("Unable to create KiWiDoubleLiteral for node value '{}' (id={}): {}", value, kiWiNode.getId(), e.getMessage(), e);
+                throw e;
             } finally {
                 result.close();
             }
@@ -903,7 +901,6 @@
             return (KiWiBooleanLiteral)element;
         }
 
-
         requireJDBCConnection();
 
         KiWiUriResource ltype = loadUriResource(Namespaces.NS_XSD + "boolean");
@@ -1177,7 +1174,6 @@
         }
     }
 
-
     /**
      * Return the identifier of the triple with the given subject, predicate, object and context, or null if this
      * triple does not exist. Used for quick existance checks of triples.
@@ -1283,7 +1279,6 @@
             }
         });
 
-
     }
 
     /**
@@ -1356,7 +1351,6 @@
             }
         });
 
-
     }
 
     /**
@@ -1418,7 +1412,6 @@
             }
         });
 
-
     }
 
 
@@ -1443,10 +1436,9 @@
         triple.setDeleted(false);
         triple.setDeletedAt(null);
 
-
         synchronized (triple) {
             if(!triple.isDeleted()) {
-                log.warn("attemting to undelete triple that was not deleted: {}",triple);
+                log.warn("attempting to undelete triple that was not deleted: {}",triple);
             }
 
             PreparedStatement undeleteTriple = getPreparedStatement("undelete.triple");
@@ -1460,7 +1452,6 @@
 
     }
 
-
     /**
      * List all contexts used in this triple store. See query.contexts .
      * @return