Search code examples
javaclassloaderwebsphere-7

How to load a Properties File when the ClassLoader is in the EJB jar and the Properties File is in war


I have this problem. I want to load a properties file located in a war file but the class loader is in another jar file. But they are compiled in one ear file. When I place the properties file in src folder of the jar file's project, it works but I wanted to put it in Web-INF/Classes for future update purposes.

Details.

Compiled in EAR EJB IBM Websphere

Thanks!


Solution

  • You war depends on your EJB but the EJB does not depends on your war.

    Thus, it's not possible.

    If configuration must be updated, you should externalize it. You won't be able to modify files in your war.

    A good practice is to generate EJB jars and WARs independtly of the environment. It will enable your Exploitation team to deploy the same code in every environment. They will just need to adapt the externalized property files (DB login / password, etc...).