Search code examples
websphere

IBM websphere: How to edit properties file inside War file


I’m new to IT and trying to figure out how to edit properties file inside the war file while deploying it in IBM websphere. I have a war file and it contains two properties file Web-inf/classes/database.properties and apps.properties? . It need to be edited before deploying the war file or can it be edited after deployment?

I have tried it in tomcat and in which I can edit it after unwrapping the war file but I’m not sure how to do it in IBM websphere.


Solution

  • You cannot edit these files easily during deployment.

    Recommended way for database properties is to use DataSources defined on the server and then just JNDI name of resource ref in the application, which actually can be mapped to the server resource during deployment.

    I dont know what is in your apps.props, but you really need to change them between environments then you could one of these:

    • rewrite your app to use JNDI entries, which you can define on the server
    • use a "shared library" approach where your apps.props file is external to your app and configured as classpath resource available via mapping shared library to the application
    • put your props file in the global server properties folder (not really recommended, as it is global)
    • have different copies and replace in the ear/war before deployment (probably the easiest one to do)
    • use wsadmin scripting to upload new apps.props file after deployment (complicates deployment, so I'd probably use one above)

    You can manually edit these props in unpacked war location on the server, but I treat it as "last resort" and not really production quality solution, as if you for example map app to the different server/cluster all your changes would be lost.

    You can also checkout old discussion about similar issue here best place to put properties file in IBM websphere 8.5?