21

In my $TOMCAT_HOME/conf/server.xml I put this near the bottom:

...

 <Context path="/staticdir" docBase="/filesystem/path/to/static/dir"/>                                

      </Host>
    </Engine>
  </Service>
</Server>

I'm doing this because I have files on my filesystem that I want tomcat to serve up when you go to localhost:8080/staticdir

But when I start the application in Intellij-IDEA the tomcat log says this:

Using CATALINA_BASE: "C:\Users\me.IntelliJIdea11\system\tomcat\Unnamed_Product_2"

If I go into that directory on my filesystem and look at the conf/server.xml file, it doesn't have the Context tag I put in there. Why is intellij modifying this and how can I prevent it?

I have a feeling I should have made this change to my $TOMCAT_HOME/conf/context.xml file instead, but I'm having trouble finding examples of how to make this change in there. If someone could show me an example of that, I'd consider it an answer, because I notice that intellij doesn't modify that file.


I have found a workaround.

enter image description here

But I really don't like this because when new users try to run the app for the first time, I can't imagine a way to detect they did this step incorrectly.

Here's a picture of my tomcat configuration:

enter image description here

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
  • 2
    I don't see so much difference in your approaches. In first case your new user has to have special configuration of Tomcat and he has that information that he needs it. In second case he has to have information about special configuration of IntelliJ. In both cases he gets same error message if he doesn't do them. I would put static content inside of your webapp, if you dont need reuse it. – chalimartines Jan 16 '13 at 11:01
  • The static content is generated during the app's runtime. I guess it's not static, it's "static". Also, I set it up so that there's a property file that points to the server.xml. If that property or prop file is missing, it gives a nice error explaining they need to exist. Once it exists, it scans the server.xml you point it to to make sure you've got that set up correct. Intellij is messing with this because it doesn't use a server.xml. How can I make the app error to explain how to set it up? – Daniel Kaplan Jan 16 '13 at 18:52
  • I meant to say, "Intellij is messing with this because it's using its own server.xml and configuring it differently from non-intellij setups" – Daniel Kaplan Jan 16 '13 at 19:21
  • 2
    You have an option to override `CATALINA_BASE` in the Run configuration and use the default one which you should configure to either use the artifact output location for deployment source or change the artifact output to go directory into `TOMCAT_HOME\webapps`. – CrazyCoder Jan 23 '13 at 08:48
  • @CrazyCoder I'm not sure if I'm looking at the right place. Is this in the "Configure..." button of the "Application Server" in the run configuration? If so, why does changing the base to point to somewhere else fix this issue? Also, if this is set (and it is), why is intellij putting my project and tomcat config files in my user directory? I've updated to include a screenshot of this. – Daniel Kaplan Jan 23 '13 at 18:14
  • 2
    See my answer at http://stackoverflow.com/a/7702077/104891 and [this screenshot](http://img547.imageshack.us/img547/8798/20130123222718.png) for the `CATALINA_BASE` override. – CrazyCoder Jan 23 '13 at 18:27
  • @CrazyCoder: That worked. If you can post that as an answer I'll mark it as correct. Thanks a lot – Daniel Kaplan Jan 23 '13 at 18:55

4 Answers4

31

By default IntelliJ IDEA modifies CATALINA_BASE environment so that Tomcat uses adjusted configuration files for deploying applications directly from the artifact output location, however it's possible to override this behavior and configure everything manually (either by changing the artifact output to go into webapps or by changing the server configuration in the same way IDEA does so that deployment occurs from the standard artifact output).

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
8

I was need ROOT context in Tomcat/IntelliJ, so in server.xml in Host tag, add specific Context :

<Context path="" docBase="C:\intranet\app\tomcat\webapps\ROOT\" reloadable="true" />

In intelliJ 11.1.5, in Server tab panel check box "Deploy applications configured in Tomcat instance", IntelliJ will copy server.xml in folder deployment :

C:\Users\{Username}\.IntelliJIdea11\system\tomcat\Unnamed_Product_2\conf"

Now I can access to resources in Root domain, by example crossdomain.xml :

http://localhost:8080/crossdomain.xml
Nexus6
  • 81
  • 1
  • 1
2

In Startup/Connection tab add the data as mentioned below in ' Pass environment variables ' section. Restart and that's it.

Name           Value
------------   -----
CATLINA_BASE   {Tomcat Installation directory}
nitinram
  • 79
  • 5
  • arent catalina_base and catalina_home supposed to be two different things? I thought base has some temporary changes that you may not want to save – Kalpesh Soni Apr 25 '18 at 15:30
0

I copied servers and found that my log files are stored in the wrong location.

So for the "Tomcat prod" it was actually using catalina.base=".../preprod/..."

I ended up editing projects/.idea/workspace.xml which was next to where I installed IntelliJ

Sebastian Saip
  • 452
  • 2
  • 5
  • 17