How to manage configuration of WebSphere Liberty for production environment

WebSphere Liberty is an application server offering by IBM. It is fast, dynamic and easy for configuration. The server is built on the open source Open Liberty project.

With the growth of WebSphere Liberty over last few years to support full Java EE 7 platform, it’s no more a tool confined to be used for quick development but has resulted in an increase in its adoption for final production environment deployment. Many of the solutions have been opting to migrate from ‘traditional’ WebSphere Application Server (WAS) to WebSphere Liberty.

If you are wondering how easy to get started with Liberty, then spend 2 minutes to watch the video:

Recently I have as well migrated my solution to WebSphere Liberty. During this migration, one issue I encountered is how to manage the configuration of data source, JNDI, shared libraries in server.xml so as not to clutter everything in a single long file. And moreover, I was looking for having a better control over the dynamic configuration values like database server details etc.

WebSphere Liberty provides two beautiful features to tackle both of these issues. First is you can use include elements to consolidate the configuration from different files. And second, you can specify the environment variable in the server.env file to customize the environment.

Datasource Configuration in WebSphere Liberty

Let me take an example of data source configuration to show above in action. Let’s create a server_ds_config.xml as below:

We can include above data source configuration XML into the main server.xml as below:

And the values of the variables used can be specified in server.env file as below:

Finally, file structure for above configuration in WebSphere Liberty should look like below:

On the similar line, we can very well segregate configurations of JNDI specification, shared library declaration, TAI configuration and even individual WAR configuration.

Before I close, include element provide many more attributes for configuration. It will be worth spending the time to explore them before you finalize your configurations.

Happy Exploring!!

Add a Comment

Your email address will not be published. Required fields are marked *