diff --git a/src/main/java/com/sothr/imagetools/App.java b/src/main/java/com/sothr/imagetools/App.java
index cec00f5..9bfb010 100644
--- a/src/main/java/com/sothr/imagetools/App.java
+++ b/src/main/java/com/sothr/imagetools/App.java
@@ -75,7 +75,7 @@ public class App extends Application
@Override
public void stop() throws Exception {
logger.info("Image-Tools is shutting down");
- AppConfig.saveProperties();
+ AppConfig.shutdown();
super.stop();
}
}
diff --git a/src/main/java/com/sothr/imagetools/AppCLI.java b/src/main/java/com/sothr/imagetools/AppCLI.java
index 6014b3e..8b3c882 100644
--- a/src/main/java/com/sothr/imagetools/AppCLI.java
+++ b/src/main/java/com/sothr/imagetools/AppCLI.java
@@ -26,7 +26,7 @@ class AppCLI {
CommandLineParser parser = new BasicParser();
CommandLine cmd = parser.parse(options, args);
process(cmd);
- AppConfig.saveProperties();
+ AppConfig.shutdown();
System.exit(0);
} catch (Exception ex) {
logger.error("Unhandled exception in AppCLI",ex);
diff --git a/src/main/java/com/sothr/imagetools/AppConfig.java b/src/main/java/com/sothr/imagetools/AppConfig.java
index fd5f6a7..c78ed30 100644
--- a/src/main/java/com/sothr/imagetools/AppConfig.java
+++ b/src/main/java/com/sothr/imagetools/AppConfig.java
@@ -1,5 +1,6 @@
package com.sothr.imagetools;
+import com.sothr.imagetools.dao.HibernateUtil;
import com.sothr.imagetools.util.ResourceLoader;
import com.sothr.imagetools.util.PropertiesService;
import com.sothr.imagetools.util.PropertiesEnum;
@@ -109,6 +110,11 @@ public class AppConfig {
}
}
+ public static void shutdown() {
+ saveProperties();
+ HibernateUtil.getSessionFactory().close();
+ }
+
public static void saveProperties() {
PropertiesService.saveConf(USERPROPERTIESFILE);
logger.debug("Saved properties");
diff --git a/src/main/resources/hibernate/Image.hbm.xml b/src/main/resources/hibernate/Image.hbm.xml
index d8d2a30..64e2b56 100644
--- a/src/main/resources/hibernate/Image.hbm.xml
+++ b/src/main/resources/hibernate/Image.hbm.xml
@@ -11,6 +11,6 @@
-
+
\ No newline at end of file
diff --git a/src/test/resources/hibernate/Image.hbm.xml b/src/test/resources/hibernate/Image.hbm.xml
index d8d2a30..64e2b56 100644
--- a/src/test/resources/hibernate/Image.hbm.xml
+++ b/src/test/resources/hibernate/Image.hbm.xml
@@ -11,6 +11,6 @@
-
+
\ No newline at end of file