Hi David,
Currently we are following similar approach to what you have suggested. There is a file called “common.jar” file in the application, which is used by both EJB and WAR modules. The property files are also present in the common.jar file. The property reader classes use ‘ResourceBundle.getBundle(“propertyFileName”
’ to load and cache the properties. As the common.jar is present in class path (in manifest.mf file), the frameworks such as log4j can see the corresponding property files. This solution is working fine but I would like to take others views/ideas on this issue.
The classloader of WEB module can pickup the classes (or property files) present in the directories WEB-INF\classes, WEB-INF\lib and context root of web module. EJB classloader can pick the classes in the root directory of ejb jar file. However, the class files in root directory of EAR file are not picked up by any classloader.
I do not wish to put the property files in the WEB modules classpath (WEB-INF\classes or WEB-INF\lib) because we have to keep the property file loading logic in a servlet. If there is Swing front end to the application in addition to web front end, using servlets to load the properties may not be a good solution.
Even if both EJB and WEB modules access the property file through a class accessible by both modules, there won’t be any multi
thread issues. The properties are read only, they would be loaded only once and cached into memory. After initial loading any module can request for the values of the properties.
Regards,
Srinivas