I'm running a webapp on Tomcat from within Eclipse, but I'm in the process of switching to use IntelliJ instead of Eclipse. For some reason, when using IntelliJ, my CATALINA_BASE
is showing a different path compared to my CATALINA_HOME
(as per the logs):
14-Feb-2019 16:14:31.171 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\schmoejoe\.IntelliJIdea2018.3\system\tomcat\Unnamed_myapp
14-Feb-2019 16:14:31.171 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\myapp\apache-tomcat-9.0.8
In my Run/Debug Configuration I specify the path to my local Tomcat (i.e., CATALINA_HOME
) on my C: drive. But as you see above, the logs show my CATALINA_BASE
at a different path, C:\Users\\...\\.IntelliJIdea2018.3\system\tomcat\Unnamed_its
.
Why did IntelliJ change my CATALINA_BASE
to be different from CATALINA_HOME
? And is there any way I can prevent that?
One reason I ask is my logs now go to that other path instead of where I expected them to go (my actual Tomcat directory). Maybe that's just how IntelliJ's Tomcat integration works? But one drawback is it seems to now preclude me from running my app(s) from my Tomcat bin\startup.bat
.
Yes, you can direct CATALINA_BASE
to be in CATALINA_HOME
.
But common practice is to use an external base folder. This keeps your original Tomcat folder pristine, in original condition. Also makes housekeeping a bit easier with multiple projects that might be making use of Tomcat. Each project with its own base folder keeps their own stuff neatly segregated.
Either way, you specify the base folder when configuring IntelliJ to know about Tomcat. Look in Preferences
> Build, Execution, Deployment
> Application Servers
. Click the +
icon button to set up a new configuration of Tomcat with IntelliJ, displaying the dialog box shown next. Click the folder icon within the Tomcat base directory
field to select your pre-configured base folder.
Note in my example screen shot my own practice. I keep Tomcat at the top of my Unix/macOS home folder. I create a folder for my various projects’ base folders named apache-tomcat-base
so it abuts the Tomcat folder(s) alphabetically. I then nest a project-specific folder, using Unix-style naming to avoid problems (no SPACE characters, simple, short) — such as example_app
seen here. I might further nest version-number named folders if I am working with different versions of Tomcat, such a 9.0.14
(not usual).
CRUCIAL: IntelliJ unfortunately refuses to configure this external base folder. I was spoiled with NetBeans doing this for me automatically. But in IntelliJ, despite having paid money for the Ultimate edition to get the Application Server support feature, I must configure the base folder manually. See my Question on this issue.
conf
folder.Lastly, set up a Run/Debug Configuration
for your web app. Access the dialog box shown next by using the pop-up menu next to the Run & Debug icons in upper-right corner of IntelliJ. Notice the Application server
field, where we select the IntelliJ-Tomcat configuration we established as shown above.
Bonus Tip: Avoid using the After launch
checkbox. Nasty bug causes my web app to double-launch within Tomcat. Just switch to the web browser manually, keep a bookmark for your localhost:8080
URL.