Easily Deploy to Tomcat Webapps Folder?

I like the way you can just run an IDEA web project using the ">" button. Nice. Everything works great ... as long as IDEA is loaded.

However, I'd also like to be able to easily deploy the application to tomcat webapps folder so it will run there without having IDEA loaded. I don't want to have to write an Ant script (yuck) to deploy to the local app server either.

Attempt 1:

So far, I don't see a quick and easy way to do just .... deploy to Tomcat's webapps folder.

I tried to add an "External" path to the Run settings (so it was there in addition to the war-exploded default), but that didn't seem to do anything. The application was not found under webapps.


Attempt 2:

Trying deploy to Tomcat's webapps folder another way....

When I copy the seemingly complete web app from the artifacts folder IDEA creates in the Artifacts directory and put it directly into Tomcat's Webapps, I get  the following error when tryng to run the application:

type Status report
message This application is not currently available
description The requested service (This application is not currently available) is not currently available.

The application also does not show up in the Tomcat Manager application as a loaded application. It has a web.xml, an index.jsp, and, well everything I would expect, but no dice. Doesn't work.


Any ideas what is going on?

I'd like to be able to deploy the exploded archive directly to Tomcat  instead of (or in addition to) the application folder so it's easily  runnable when IDEA isn't loaded.

I've been needing to know how to do this for a while so I'd really like to know what the magic is. It's not obvious (to me, that is) how to do this.

If this easy deploy capability isn't currently in IDEA, which I doubt is the case, please let me know and I'll add an "urgent" request to have it added.

If the easy deploy capability is available, what are the set of steps required to set it up?


- m


I'm not sure why you got the error when deploying the war file artifact to Tomcat directly. That should work. I've done it hundreds of times. Try it with a simple Hello World webapp and see what happens. It might point out a problem with your webapp.

When you run a Tomcat webapp in Intellij IDEA, it is deployed to the directory .IntelliJIdea11\system\tomcat\${runConfigurationName}_${projectName}  (See http://devnet.jetbrains.net/docs/DOC-181 for information on the location of the .IntelliJIdeaXX directory.) IDEA sets that directory as the CATALINA_BASE for Tomcat. (If you are not familiar with the difference between CATALINA_HOME and CATALINA_BASE, you can read about it in the Tomcat documentation: https://tomcat.apache.org/tomcat-7.0-doc/introduction.html#Directories_and_Files) If you look at the top of the output when you start Tomcat inside Intellij IDEA, you will see something like this:

Using CATALINA_BASE:   "C:\Users\Me\.IntelliJIdea11\system\tomcat\My_Webapp_example-webapp"
Using CATALINA_HOME:   "C:\apps\tomcat-7"
Using CATALINA_TMPDIR: "C:\apps\tomcat-7\temp"
Using JRE_HOME:        "C:\Java\1.7-x64"
Using CLASSPATH:       "C:\apps\tomcat-7\bin\bootstrap.jar;C:\apps\tomcat-7\bin\tomcat-juli.jar"

If you want to run the webapp outside of IDEA, write a simple script to set the CATALINA_BASE and CATALINA_TMPDIR environmental variables and then call the startup script in Tomcat's bin directory. For example:

@echo off
set "CATALINA_BASE=C:\Users\Me\.IntelliJIdea11\system\tomcat\My_Webapp_example-webapp"
set "CATALINA_TMPDIR=C:\apps\tomcat-7\temp"
call "C:\apps\tomcat-7\bin\startup.bat"

Use that script to start Tomcat. It will start Tomcat with the webapp you last deployed via that Tomcat Run/Debug Configuration. You could also set those variables for the system rather than using a script; but of course that means you would always run that webapp when starting Tomcat.

I hope that helps.


I don't think it's a problem with the web app since it runs fine when clicking the ">" button in IDEA 12. It's a simple Servlet with JSP.

And, this problem is not new.

Here's the functionality I want to be able to do within the IDEA interface: be able to easily just give IDEA the actual Tomcat webapps folder to use for deploymnent (as, say, a simple configuration option inside the interface itself). Then, when I click the ">" button, it deploys there. Then, when I'm done with IDEA, the web app is .... still deployed. This is the part I can't get working. When IDEA isn't running the app, regardless of where it's deployed, it no longer works.

That's the way MyEclipse works. MyEclipse makes depoyment something that just works as you'd expect. A couple clicks. It's so simple and it works everytime. Hot depoy is built right in too with nothing extra required.

Why, in IDEA, I should have to ....

1. Root around in hidden files (on Mac), or

2. Write a "special" script, or ...

3. Whatever else

is just beyond me.

I'm amazed that IDEA isn't more flexible. Here again, I find that I'm spending hours trying to do something which should be easy -- which is EXTEMELY easy in MyEclipse. IDEA is not helping me as much as it should or could. IDEAs interface in many areas, Run Configurations among them, is baffling, and for me, rarely works.

Even when I configure a project to deploy to Tomcat, I get:

type Status report
message This application is not currently available
description The requested service (This application is not currently available) is not currently available.

When trying to run it.

I love IDEA as a Java .... editor. It's the best. Debugger good. SQL/Database good, etc.. But these other rough edges, like needlessly confusing deployment, keep me from really being able to use it for much in a production environment.

Since version 9 (I'm on 12), the product has bascially added more features, not IMHO, made any of the exiting product easier or more intiutive to use.


- m


Idea offers this at least last 8 or so years:

just go to project settings and than create extra artifacts,  which will point to your external tomcat directory (use copy option of existing exploded or war artifacts).


I've tried this ... This doesn't work either as expected.

I can delpoy the app, but trying to run the app directly from just Tomcat (without IDEA running it) I get:

type Status report
message This application is not currently available
description The requested service (This application is not currently available) is not currently available.



But, if I run the app from IDEA (still in the Tomcat webapps folder), it works!


This is baffling.

All the directories look correct

What is going on?


-- m


Mork! wrote:

This is baffling.

What is going on?

I explained what's going on in my previous post; IDEA deploys webapps to a specific CATALINA_BASE. It does not use CATALINA_HOME as the CATALINA_BASE.  So when you start Tomcat without specifying an alternate CATALIN_BASE, the web application is not available.  Again, if you do not understand what that means, please read the link I provided in my previous post. Using an alternate CATALINA_BASE has several advantages, and can be considered a best practice. The primary advantage, from a development standpoint, is that I can have multiple instances or versions of the same webapp running (on different ports) at the same context. This is sometimes useful during development. It also sandboxes the web application inside a separate Tomcat and JVM.

To the best of my knowledge, you cannot configure IDEA to deploy a webapp to CATALINA_HOME rather than a defined CATALINA_BASE. This leaves you with two options:

  1. Use a simple script, such as the four line script I showed in my previous post, to start Tomcat outside of IDEA
  2. Copy the WAR file IDEA builds into the webapp directory of your CATALINA_HOME

You stated you tried the second option but received the application not found error. If you were attempting to go to http://localhost:8080/TestServlet did you configure the IDEA build to name the war file ROOT.war? If not, did you rename the war file to ROOT.war?  If not, did you configure a tomcat <context> to use the root context? If you did not do any of those things, then you need to use the URL http://localhost:8080/NameOfWarFile/TestServlet In IDEA, in a Tomcat run/debug configuration you can define the context path that differs from the war file's name. IntelliJ IDEA sets that in the<context> definition within a file it generates and places within the %CATALINA_BASE%/conf/Catalina/localhost If you use Tomcat's auto-deploy to deploy the war file (i.e. you copy the war file to the webapps directory) Tomcat deploys the application to a context equal to the name of your war (assuming you are not defining a context in a Tomcat <Context> definition).  If you copy the built artifact "MyWebapp.war" to your Tomcat webapps directory, you need to go to the context /MyWebapp to access the webapp. So if you want to go to TestServlet in MyWebapp.war, you need to go to the URL http://localhost:8080/NMyWebapp/TestServlet If you want it so you can access it at the URL http://localhost:8080/TestServlet you need to deploy the war in the root context. To do that, delete the default ROOT directory in the Tomcat installation's webapps directory, rename your war file to ROOT.war (or configure IDEA to build it with that name), and place the ROOT.war file into the webapps directory.

I suggest you read the Tomcat documentation so you can better understand how Tomcat defines contexts. The book Tomcat: The Definitive Guide, Second Edition (ISBN-13: 978-0-596-10106-0) by: Jason Brittain and Ian F. Darwin also does a great job of explaining these concepts.


The problem seems to be that I'm having a Major Minor issue with the Servlet not being loadable. Something wrong on my Mac, seemingly.

I've updated Java 7 to the latest for both JDK and Runtime.

Launching Tomcat from the command line shows the correct Java version.

Yet, trying to load the Servlet, I get:

type Exception report
message net/test/servlets/MyServlet : Unsupported major.minor version 51.0 (unable to load class net.test.servlets.MyServlet)
description The server encountered an internal error that prevented it from fulfilling this request.

java.lang.UnsupportedClassVersionError: net/test/servlets/MyServlet : Unsupported major.minor version 51.


The problem was in Catalina.sh. The "export JAVA_HOME"
was pointing to a Java 6 version I didn't even know existed
on the computer (/Library/Java/Home).
Changing the export fixed things right up
and the Servlet is working fine now.

IDEA was never at fault. And, it seems quite easy to
deploy to the Tomcat folder as I've wanted to.

I appreciate the thoughtful comments presented here
today and the excellent technical support by Serge
at JetBrains.

Thanks again to all. :)

- m


Please sign in to leave a comment.