Open chakravarthi2u opened 1 year ago
server.env sets process system environment variables that can be gotten from the System.getenv() method in Java. Processes and Java do not have a way to have more than one set of system environment variables.
By providing more details about what you are trying to accomplish, we may be able to come up with a solution. System environment variables aren't going to be the way you are going to be able to do it if you need two applications in the same server have different values for the same variable since a system variable can only have one value.
I have one web application running in liberty server which will connect to backend server(specified as properties) in server.env
I want to run one more similar application points to different backend server. In this case, i cant use same property in server.env file. That is i want to customize backend server urls in different server.env files and wants to point in webApplication section in server.xml file.
<webApplication contextRoot="/" location="app.war">
<server.env.includes path="server.env.1"/>
</webApplication>
<webApplication contextRoot="/test" location="app2.war">
<server.env.includes path="server.env.2"/>
</webApplication>
Both server.env.1 and server.env.2 files will have almost same properties with different values. These files will be used by applications.
As Jared said you cannot use server.env file for this. The server.env file is to provide the environment for the server. It is processed in the shell by the shell and can only apply process wide. This isn't a Liberty limitation, but this is a limitation produced by the shell and Java.
Perhaps if you explained how your applications will be accessing this configuration we might be able to suggest alternative options, but if you really need to read this from the environment you would need two servers.
Thanks for the details. I will consider these points.
Dear Liberty team,
I have two web applications app1 and app2. app1 will use server.env.app1 and app2 will use server.env.app2.
How to configure server.xml webApplication section to configure different server.env files for each deployed applications?
Thanks for helping.