Loading properties file in EJB module
We are having an odd loading problem that I am hoping the collective expertise here can help with. Within an EJB module, we are loading a properties file via getResourceAsStream(). This is being done in a SLSB. The properties file is present in the resulting EJB module at the root of the built jar file. In the code, I am dumping the classpath to make sure at runtime, the file is where the server should be finding it.
The code to load the properties file - boiled down for space, but syntactically identical. See attached file for the test app written to troubleshoot this issue.
Properties props = new Properties();
URL url = getClass().getClassLoader().getResource(fileName); // url is null after this
if (url == null)
System.err.println("Can't find props file");
I am dumping the classpath with this hack:
com.ibm.ws.classloader.CompoundClassLoader cl = (com.ibm.ws.classloader.CompoundClassLoader).getClass().getClassLoader();
and it shows the EJB jar as the last entry, and I have opened the EJB JAR right on the filesystem on WAS and can see the properties file there.
So, the properties file definitely seems to be on the classpath, but just will not be found at runtime.
Here is the kicker. This is happening in some environments, but not all. The same EAR file is deployed in one environment and it works. In at least two of our environments, it will not work. All are 184.108.40.206. Can anyone think of a reason how/why this might be happening? Some kind of config?