views:

697

answers:

1

So I'm trying to add some ability to my project to allow user-defined properties in my deployment artifact - a simple key:value .properties file. I place the service.properties file in

war/WEB-INF/my-service.properties

And in my ServiceImpl.java constructor I have the following:

String propertiesFileName = "my-service.properties"; 

URL propertyURL = ClassLoader.getSystemResource(propertiesFileName);
URL propertyURL2 = this.getClass().getClassLoader().getResource(propertiesFileName);
URL propertyURL3 = this.getClass().getClassLoader().getResource( "WEB-INF/" + propertiesFileName);
URL propertyURL6 = this.getClass().getClassLoader().getResource(
       "E:/Projects/eclipse-workspace/projectName/war/WEB-INF/" + propertiesFileName);

All instances of Property URL are null. I know I'm missing something absolutely obvious, but I need a second pair of eyes. Regards.

EDIT:

Ah, it seems I was confused as the default GAE project creates a logging.properties file in /war. From the Google App Engine documentation:

The App Engine Java SDK includes a template logging.properties file, in the appengine-java-sdk/config/user/ directory. To use it, copy the file to your WEB-INF/classes directory (or elsewhere in the WAR), then the system property java.util.logging.config.file to "WEB-INF/classes/logging.properties" (or whichever path you choose, relative to the application root). You can set system properties in the appengine-web.xml file, as follows:

+2  A: 

Try putting the service.properties in WEB-INF/classes. Then it should be accessible just with :

this.getClass().getClassLoader().getResourceAsStream("/filename.properties");
jsight