1
votes

I created a Play! app and deployed it under TomCat. This works well. The only problem is the management of a properties file, currently in the conf folder right next to application.conf. But as soons as the client replaces the war file the custom properties are overwritten with the default values, resulting in errors.

Now I want to introduce a seperate properties file placed inside the webapps folder. This way I will be sure my clients will not overwrite the file 'accidentally'.

So the structure would be:

TomCat webapps:
    myPlayApp
    PlayConfig <-- here I want to place the config file

So I would like to retrieve the properties file by something like:

getFile("../PlayConfig/app.properties");

This obvious does not work, but I do not know how to achieve this? I thought retrieving it by tomcat http url but the portnumber my vary, so this would also not work, I guess...

UPDATE 2012-01-25:

Actually when using the following code:

Play.applicationPath.getPath();

I get the absolute path when running the project outside tomcat (so not inside war file!)

When I deploy the same project in a TomCat server I get the following output:

W:\tomcat-5.5\webapps\MyTestProject\WEB-INF\application.

From this point on I can indeed use a relative path.

1
This will not solve this particular problem but have you thought of persisting the properties in a database instead?emt14
Yes I have thought about this but I do not want to create a database just for a few properties. And I already have a client database where I get my data out and I cannot put my own things in that client database..adis

1 Answers

0
votes

I think that when deployed in a Servlet container, play uses the /WEB-INF/application as base directory. Try changing the path relative to this folder.