I’m developing a GWT web application and while deploying to Tomcat, I face a problem.
The problem is quite simple but I don’t know how to fix it without telling Tomcat where to look for these files.
When I deploy my app right out on to Tomcat, it looks for the files in the /bin directory so if I place the log4j.properties and my jaas.conf in there it works like a charm.
The thing is I would like to be able to keep those files within my webapp.
How can I do it?
Is there anything I can add to the web.xml?
I tried to put both files into the /WEB-INF/classesdirectory but it didn’t work out.
When I run my projects in Eclipse my jaas.config has to be in the /war folder while my log4j.properties stays in the /src folder.
Edit :
I read this and and tried it even if I don’t use log4j for Tomcat internal logging but it didn’t work either.
I use Tomcat 7.0
This answer will fit my particular problem but anyone can surely adapt it to make it works in his project.
My project had two servlet depending on external files. To centralize these external files into my webapp folder, I used a third sevlet to set the location of the files. In my GWT web.xml, I add the
StartUpServletand I set it to be loaded first by my Servlet Container (Tomcat). Here is my web.xml :In this
StartUpServlet, I set the files location like so : (There might be a better way to do it, but it worked) :Basically, I get the ServletContext real path so it gives me, on Tomcat, the following path :
${CATALINA_HOME}/webapps/<myapps>Then I use this to set the file locations : config/config.properties, config/log4j.properties and my config/JaasConfig.
Once they are set I can use them in my other servlets like this
System.getProperty(KEY);Thanks to @Aviram for helping me to set the location of the JaasConfig.