diff --git a/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java b/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java
--- a/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java
+++ b/src/org/openbravo/mobile/core/servercontroller/ServerStateBackground.java
@@ -476,8 +476,13 @@
           pingServer(serverId, parameters, queryParams);
         }
         OBDal.getInstance().commitAndClose();
-      } catch (JSONException e) {
-        throw new OBException(e);
+      } catch (Throwable t) {
+        try {
+          OBDal.getInstance().rollbackAndClose();
+        } catch (Throwable ignore) {
+          // ignore
+        }
+        throw new OBException(t);
       } finally {
         OBContext.restorePreviousMode();
       }
