ec-jrc / re3gistry

Re3gistry is a reusable open source solution for managing and sharing ‘reference codes’, ensuring semantic interoperability across organisations.
European Union Public License 1.2
29 stars 21 forks source link

Location of system.installed #81

Closed heidivanparys closed 2 years ago

heidivanparys commented 2 years ago

I added logging to Configuration to show what file the system is checking exactly to determine whether the system has been installed, see also https://github.com/heidivanparys/re3gistry/commit/566743c4a7b7ef5746a21fd455982bd28b841364

This gives the following:

[TRACE] 2021-11-12 14:33:55.525 [http-nio-8080-exec-199] [utility.Configuration.checkInstallation:118] - Checking for existence of file /usr/share/apache-tomcat/webapps/re3gistry2restapi/WEB-INF/classes/configurations_files/system.installed
[TRACE] 2021-11-12 14:33:55.525 [http-nio-8080-exec-199] [utility.Configuration.checkInstallation:121] - The system has been installed

Which is interesting since the application I am using at that time is re3gistry2, and not re3gistry2restapi (those lines also come from re3gistry.log). So I am wondering what could be the cause of this, I would have expected to see Checking for existence of file /usr/share/apache-tomcat/webapps/re3gistry2/WEB-INF/classes/configurations_files/system.installed in the log.

Background: I wanted to update an existing installation, and it seems that the only way of doing that is first adding an empty system.installed file and then building again with Maven. To be sure, I added that file twice:

heidivanparys commented 2 years ago

After some investigation, it turns out that the path that is checked depends on which web application was started first on Tomcat...

So depending on that the log output changes between /usr/share/apache-tomcat/webapps/re3gistry2/WEB-INF/classes/configurations_files/system.installed and /usr/share/apache-tomcat/webapps/re3gistry2restapi/WEB-INF/classes/configurations_files/system.installed...

That is problematic for the loading of configuration.properties, but also for the check/creation/deletion of file system.installed, system.installing and solr_complete_indexing.running.

The properties files are now loaded using something like:

properties = new Properties();
String propertiesPath = System.getProperty(BaseConstants.KEY_FOLDER_NAME_CONFIGURATIONS);
try (InputStream input = new FileInputStream(propertiesPath + File.separator + BaseConstants.KEY_FILE_NAME_CONFIGURATIONS)) {
 properties.load(input);
}

I would expect e.g. something like

properties = new Properties();
try (InputStream input = Configuration.class.getResourceAsStream("/" + BaseConstants.KEY_FOLDER_NAME_CONFIGURATIONS + File.separator + BaseConstants.KEY_FILE_NAME_CONFIGURATIONS)) {
    properties.load(input);
}

This issue affects eu.europa.ec.re3gistry2.base.utility.Configuration, eu.europa.ec.re3gistry2.web.controller.Install and eu.europa.ec.re3gistry2.javaapi.solr.SolrHandler (those contain the line System.getProperty(BaseConstants.KEY_FOLDER_NAME_CONFIGURATIONS).

emanuelaepure10 commented 2 years ago

Dear @heidivanparys You point it out very well. This is a well know problem for us, is on our TODO list. If you have already implemented the solution you suggested please feel free to share it with us. Thank you in advanced