Copy directory structure to Tomcat


I need to copy a directory (with its subdirectories) from my Tomcat\etc to the ${CATALINA_BASE}\etc directory.

Suppose my TOMCAT_HOME is /home/bdusauso/tomcat.
Inside ${TOMCAT_HOME} there is the /etc directory which contains files and subdirectories.

When deploying my app to tomcat, IntelliJ takes /home/bdusauso/.IntelliJIdea12/system/tomcat as CATALINA_BASE.
But my application needs files in the /etc subdirectory of CATALINA_BASE :

org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is /home/bdusauso/.IntelliJIdea12/system/tomcat/Unnamed_plmrep_4/etc/plmrep/ (The system cannot find the path specified)

So, how can I tell IntelliJ to copy this directory at the right place ?


Comment actions Permalink

To the best of my knowledge, there is not a way to directly configure IDEA to do this. You could write a very simple Ant script, using the Copy task, to copy the files. In your Tomcat run configuration, you can add that ant task to "Before launch" section so it runs prior to Tomcat starting.

However, IMHO, I think that makes your application rather brittle. It would be better to either have that properties file loaded from as classpath resource, or defined as a system property, web app config param, or some other type of configuration item defining the location of the file.

Comment actions Permalink

Thanks for the hint.
Unfortunately the institution for whom I work has a strict and weird structure for webapps and has predefined tomcat environments, so I cannot change settings easily.
I'll try what you've suggested.


Please sign in to leave a comment.