Search code examples
eclipsewebsphere-libertyopen-liberty

Publishing application settings with Open Liberty and Eclipse


I'm using WebSphere Application Server Liberty Tools on Eclipse 2020-03, testing out its WST/JST capabilities.

Setting up a Liberty server definition and adding an application to it is pretty straightforward, however what I'm missing is the ability to provide application-specific Liberty configuration along with the application.

When I add an application to a Liberty server, I can see how server.xml is modified by having a webApplication element added to it. Is the user expected to manually edit the contents of this element after deployment?

If not (and hopefully so), how can I have application-specific configuration delivered to the server.xml file (or even to the dropins directory) during publishing time? Perhaps there's a location in the application's directory where such XML files can be placed, so they're automatically published to Liberty?

EDIT example for application-specific configuration:

<webApplication id="myapp" location="myapp.war" name="myapp">
    <web-bnd>
        <resource-ref binding-name="abc" name="def"/>
    </web-bnd>
</webApplication>

Solution

  • You can use the <include> element to include server config from other files/locations, see https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/cwlp_config_include.html You would move the webApplication element to another xml file, and add an include pointing to it.

    The location attribute of the <include> element has always been able to make use of environment variables. Recently (maybe 20.0.0.2), support was added to Open Liberty to allow the use of bootstrap properties and server config variables (which would wouldn't make much sense in your use case).

    More information on variables can be found here: https://www.ibm.com/support/knowledgecenter/en/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_setup_vars.html