cancel
Showing results for 
Search instead for 
Did you mean: 

How to read property files?

martin_schffler
Participant
0 Kudos

I have a problem with a small web-app that I try to use on a SAP J2EE server.

The app was developed and tested on JBoss and there it was no problem to read the properties file with the following code:


...
URL resource = getClass().getResource("/WEB-INF/my.properties");
propertyStream = resource.openStream();
Properties properties = new Properties();
properties.load(propertyStream);
...

The properties file is deployed in the WEB-INF directory of the WAR. Seems the class loader can't find that file.

Could anybody explain what's wrong with the above code?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

By default, the directory WEB-INF is not part of a web application's classpath.

Put the properties file into WEB-INF/classes and use


URL resource = getClass().getResource("/my.properties");

to load it.

Best regards,

Jens

Answers (0)