How to externalize properties files

I am playing with Flowable in a VPS, and in order to make it work, I had to change all the application endpoints in all the applications by touching the file flowable-ui-app.properties

Isn’t there a way to add those properties in another path that is not inside <app.war>/WEB-INF/classes/META-INF/flowable-ui-app ?

The reason for asking this is to avoid losing changes in the case Tomcat redeploy the war files.

Thank you

1 Like

Ok, forget about my question.

Answering my own question, I have just found the answer in the docs

Usually, you will want to change the default H2 in-memory database configuration to a MySQL or Postgres (or other persistent database) configuration. You can do this per app by changing the flowable-ui-app.properties file in the WEB-INF/classes/META-INF directory of each app. But it’s easier to copy the flowable-ui-app.properties file from one of the apps or get it from Github, and put it in the Tomcat lib folder. The UI applications will first look at a flowable-ui-app.properties file available on the classpath directly and this configuration will have precedence over the configuration file in the WAR. To change the default configuration to MySQL the following changes are needed to the properties file:

Thank you anyway

Hi,

I thought I would add my own alternative solution. I don’t like the idea of adding the properties file directly to the Tomcat lib directory. I would sooner not clutter up the lib directory with application specific properties like this as it can be a pain to maintain.

Instead, add a context XML file for the tomcat deployment that remaps an external properties file into the WEB-INF directory. This way Flowable will pick it up as being on the classpath even if its outside of the WAR file.
In practice:

Create a file at $CATALINA_HOME/conf/Catalina/localhost/flowable-task.xml with the content:

<Context>
  <Resources>
    <PreResources className="org.apache.catalina.webresources.FileResourceSet"
            base="/path/to/external/properties/files/flowable-ui-app.properties"
            webAppMount="/WEB-INF/classes/flowable-ui-app.properties" />
  </Resources>
</Context>

You will need a context file for each Flowable app that is deployed (e.g. flowable-idm, flowable-modeler, etc). This then acts as if the the file at /path/to/external/properties/files/flowable-ui-app.properties is present at $CATALINA_HOME/webapps/flowable-task/WEB-INF/classes/flowable-ui-app.properties

This then allows the properties files to be kept in a specific folder without cluttering up the Tomcat lib folder.

/ Paul

2 Likes

Hey. Thank you for taking the time to answer.

Yes, your idea is good, but for now, I don’t mind having the configuration inside the lib folder, as by doing so, even though it is not the best place, it is in a single place, that I can “control”.

I will consider your approach when I start using Flowable in production.

This is my first test, and this server is just a playground.

Regards.

The $CATALINA_HOME/lib approach did not work for me for some reason and I like the Context XML approach much better since it is Web app specific. However there is a mistake in the above directions for Version 6.1.0 in that the flowable-task.xml should be changed to :

<Context>
  <Resources>
    <PreResources className="org.apache.catalina.webresources.FileResourceSet"
            base="/path/to/external/properties/files/flowable-ui-app.properties"
            webAppMount="/WEB-INF/classes/META-INF/flowable-ui-app/flowable-ui-app.properties" />
  </Resources>
</Context>

Note the extra path segment /META-INF/flowable-ui-app

1 Like