related to issue 38520: catch Throwable
authorCarlos Aristu <carlos.aristu@openbravo.com>
Mon, 21 May 2018 12:30:20 +0200
changeset 33994 c7d184de88d8
parent 33993 0ac5c4647a10
child 33995 915bf19e1d5b
related to issue 38520: catch Throwable

catch Throwable to avoid the failure of the export.database task which is throwing a NoClassDefFoundError when trying to recover the DalSessionFactoryController with weld
src/org/openbravo/dal/core/DalLayerInitializer.java
--- a/src/org/openbravo/dal/core/DalLayerInitializer.java	Mon May 21 10:50:06 2018 +0200
+++ b/src/org/openbravo/dal/core/DalLayerInitializer.java	Mon May 21 12:30:20 2018 +0200
@@ -98,8 +98,10 @@
     DalSessionFactoryController dsfc;
     try {
       dsfc = WeldUtils.getInstanceFromStaticBeanManager(DalSessionFactoryController.class);
-    } catch (Exception ex) {
-      log.debug("Could not instantiate DalSessionFactoryController using weld", ex);
+    } catch (Throwable t) {
+      // retrieving the DalSessionFactoryController instance with weld can fail in some build tasks
+      // or when executing the tests
+      log.debug("Could not instantiate DalSessionFactoryController using weld", t);
       dsfc = OBProvider.getInstance().get(DalSessionFactoryController.class);
     }
     if (sqlFunctions != null && !sqlFunctions.isEmpty()) {