[How To] Specify Tomcat Cache Directory For Webapp

Ok, here is the situation. I have a parent pom that contains two modules ... one is a REST service module (war) and the other is the website (also war). I am trying to run both webapps in IntelliJ at the same time. I have a run configuration for the service webapp that points to it's own CATALINA_BASE. And I have another run configuration for the website webapp that has it's own CATALINA_BASE. The separate bases contain app specific versions of server.xml and context.xml for each app. The first app (service module) starts up fine. However, when I try to start up the website, it tries to use the same IntelliJ cache directory as the service war and they step all over each other.

Here is the path that it tries to use:


And what I'd like it to use is:




Again, I can see that it is caching the version of server.xml from my CATALINA_BASE folder. It's just that both submodules use the same cache directory when running in IntelliJ because they both have the same parent pom.

Ideas? (Note: I realize I could change the pom structure, but I'm trying not to go there ... my colleague is able to do this in Eclipse and I want to be able to say that we can do it in IntelliJ too.)
Comment actions Permalink

The naming convention for that directory (called the Base Directory Name) is actual ${run_configuration_name}_${project_name}. (It just happens that your project name is named the same as your parent pom). The value used is created when you first create the run/debug configuration. However, it is not updated if/when you rename a run/debug configuration. This, IMHO, is a bug. I have reported it via IDEA-133536. Please vote for it.

So in your case, it looks like the first time you created each of those run/debug configuration, you did not change the name of the run/debug from its default of "unnamed" and that name was used when the Base Directory Name was created. As a result, you have to configurations that are using the same Base Directory Name. You have two options as a workaround:

  1. Recreate your run/debug configurations ensuring you give them a unique name when you first create and save them
  2. Manually edit the run/debug configuration file and modify the value for the BASE_DIRECTORY_NAME option (just search for that string). If you have shared the run/debug configuration (via the "share" option in the upper right corner), the configuration file will be in ${project_directory}/.idea/runConfigurations/${runConfigurationName}.xml. If it is not shared, it will be in the file  ${project_directory}/.idea/workspace.xml. You should close the project before editing either of those files (and make a backup just in case)
Comment actions Permalink

Yep, that was it. I've voted for the defect ... lost a lot of time today on this. But thanks for your help.


Please sign in to leave a comment.