From e6809d4db7d67c9e7c9dada509ebf8008ac70052 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Mon, 1 Aug 2016 15:35:27 +0000 Subject: [PATCH] Fixing the way to get properties from file git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@130930 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../dbinitialization/DatabaseEnvironment.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java index 0222d42..b02c065 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -3,8 +3,6 @@ */ package org.gcube.informationsystem.resourceregistry.dbinitialization; -import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -23,7 +21,7 @@ public class DatabaseEnvironment { private static Logger logger = LoggerFactory.getLogger(DatabaseIntializator.class); - private static final String PROPERTY_FILENAME = "config.properties"; + public static final String PROPERTY_FILENAME = "config.properties"; public static final String HOST; public static final String HOST_VARNAME = "HOST"; @@ -73,12 +71,10 @@ public class DatabaseEnvironment { Properties properties = new Properties(); InputStream input = null; - File propertyFile = new File(PROPERTY_FILENAME); try { - logger.trace("Going to load property file {}", propertyFile.getAbsolutePath()); - input = new FileInputStream(propertyFile); + input = DatabaseEnvironment.class.getClassLoader().getResourceAsStream(PROPERTY_FILENAME); // load a properties file properties.load(input); @@ -112,7 +108,7 @@ public class DatabaseEnvironment { DEFAULT_PASSWORDS.put(PermissionMode.WRITER, DEFAULT_CREATED_WRITER_USER_PASSWORD); DEFAULT_PASSWORDS.put(PermissionMode.READER, DEFAULT_CREATED_READER_USER_PASSWORD); } catch(Exception e){ - logger.error("Unable to load properties from {}", propertyFile); + logger.error("Unable to load properties from {}", PROPERTY_FILENAME); throw new RuntimeException("Unable to load properties", e); } }