One build for multiple applications


I want to build a war from my project and then use that same war for multiple (customer) applications. There are some properties that need to match the final url and that exist in the war already:

cuba.webHostName =
cuba.webAppUrl =

Here the /customer may vary as well as the ‘’. Is there any way to override these properties when deploying in production?

I’m using docker and do a number of overrides already to the different images but I can’t seem to override properties in the war file.

One option could be to allow for Java defines (like -Dcuba.webAppUrl= and have that applied for the application but again, I do not see how to do that.

Any suggestions?


you can just define the mentioned in an external properties file. This way, you can just build your war file and place a file right next to it which defines the external configuration options.

In this case you would to something like:
docker run -v /path/to/external/ my-cuba-app-container

One other alternative is to bake the in the container but not into the war file. So instead of using the volume feature of Docker you can create a Dockerfile that extends from your normal docker image where you add a into the Container.

For something like this can be as described here.

The third option is to externalize the the properties as OS environment variables (which are the base primitives for configuration options in the docker world). This would be something like this:
docker run -e CUBA_WEB_APP_URL= -e my-cuba-app-container
This would require anything that takes the environment variables and place it into the or somewhere else where the tomcat can pick it up.

For this you can find an example in this article (as a side not, but anyways):


1 Like

I would add that as long as Java system properties override application properties with the same name (see, you should be able to specify the JAVA_OPTS environment variable which is used by standard Tomcat launch scripts and define your properties in it like this:

JAVA_OPTS="-Dcuba.connectionUrlList=http://somehost:8080/app-core -DmyProperty=myValue"

Got it to work - thanks!

I guess the different options in your approach would work but I applied the solution by Konstantin as it fitted my setup most conveniently.

But thanks for sharing.

it’s an old topic, but it can be useful to others…
So I want to add that if you’re using UberJAR deploy method, with embedded Jetty, you can make even your embedded jetty-env.xml config dynamic by using SystemProperty tag:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-" "">
<Configure id='wac' class="org.eclipse.jetty.webapp.WebAppContext">
    <New id="CubaDS" class="">
            <New class="org.apache.commons.dbcp2.BasicDataSource">
                <Set name="driverClassName">org.postgresql.Driver</Set>
                <Set name="url"><SystemProperty name="app.jetty.mainds.url" default="jdbc:postgresql://localhost/mylocaldb"/></Set>
                <Set name="username"><SystemProperty name="app.jetty.mainds.user"/></Set>
                <Set name="password"><SystemProperty name="app.jetty.mainds.password"/></Set>
                <Set name="maxIdle">2</Set>
                <Set name="maxTotal">20</Set>
                <Set name="maxWaitMillis">5000</Set>

here the three properties starting with app.jetty.mainds are custom java props, and you can define them in the usual ways.


1 Like