Help with war-context

Hi!

It’s possible to deploy a war in a server (Tomcat) using an external file war-context.xml?

I need to indicate the war a specific path from the server where is the context file

Any help?

Hello @UserNacho

You can specify custom war-context.xml via coreContextXmlPath property:

task buildWar(type: CubaWarBuilding) {
    includeJdbcDriver = true
    includeContextXml = true
    singleWar = false
    appProperties = ['cuba.automaticDatabaseUpdate': true]
    appHome = '../app_home'
    // specify custom context here
    coreContextXmlPath = 'modules/core/web/META-INF/custom-war-context.xml'
}

Regards,
Daniil

The problem is that I need app.war use an external context file and use an especific external path, so that I can change the context file before start the Tomcat server, without unzip and return to create a new app.war

You can write your own Gradle task to put custom context configuration while building app distribution. Please check an example here: link

Hi @UserNacho,

Look at the Tomcat feature explained here in the docs:

Catalina/localhost – in this directory, context.xml application deployment descriptors can be placed. Descriptors located in this directory take precedence over the descriptors in the META-INF directories of the application. This approach is often convenient for the production environment. For example, with this descriptor, it is possible to specify the database connection parameters that are different from those specified in the application itself.
Server-specific deployment descriptor should have the application name and the .xml extension. So, to create this descriptor, for example, for the app-core application, copy the contents of the webapps/app-core/META-INF/context.xml file to the conf/Catalina/localhost/app-core.xml file.

Thank you very much!