IntelliJ IDEA – Run / debug web application on Tomcat

This article shows you how to run or debug a web application on Tomcat server, using IntelliJ IDEA.

Note
Unlike Eclipse IDE, there is always a ‘server view’ to configure the add server, IntelliJ do things differently, you need to add an “artifact (war file)” first, then only the “server view” will be displayed at the bottom.

1. Tomcat Plugin

1.1 File –>> Settings –>> Type Plugin –>> Make sure Tomcat and TomEE Integration is checked.

idea-run-debug-tomcat-example

2. Run/Debug Configuration

2.1 Run –>> Edit Configurations…

idea-run-debug-tomcat-example1

2.2 Clicks + icon, select Tomcat Server –>> Local

idea-run-debug-tomcat-example2

3. Tomcat Configuration

3.1 Clicks on the “Deployment” tab, + icon to select an artifact to deploy. For break point debugging, always choose the exploded war version.

idea-run-debug-tomcat-example4

3.2 Clicks on “Server” tab, select a Tomcat server, and update the on 'Update' action to “Update classes and resources” – for hot swap.

idea-run-debug-tomcat-example5

4. Application Servers

4.1 Now you can see an “Application Servers” view displayed at the bottom panel.

idea-run-debug-tomcat-example6

Start or debug your web application, done.

32 comments on “IntelliJ IDEA – Run / debug web application on Tomcat

  1. I followed steps mentioned by mkyong, but its my bad luck that my tomcat server not started. Also not getting any error on tomcat log. Below result appeared in log file. Can anyone please suggest where i was wrong.
    C:\ETLProduct\Tomcat-9.0.12\bin\catalina.bat run
    [2020-04-10 04:27:25,096] Artifact goetldashboard:war exploded: Waiting for server connection to start artifact deployment…
    Using CATALINA_BASE: “C:\Users\rmishra\.IntelliJIdea2019.1\system\tomcat\Unnamed_goetldashboard_2”
    Using CATALINA_HOME: “C:\ETLProduct\Tomcat-9.0.12”
    Using CATALINA_TMPDIR: “C:\ETLProduct\Tomcat-9.0.12\temp”
    Using JRE_HOME: “C:\Program Files\AdoptOpenJDK\jre-8.0.242.08-hotspot”
    Using CLASSPATH: “C:\ETLProduct\Tomcat-9.0.12\bin\bootstrap.jar;C:\ETLProduct\Tomcat-9.0.12\bin\tomcat-juli.jar”
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.12
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Sep 4 2018 22:13:41 UTC
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.12.0
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\AdoptOpenJDK\jre-8.0.242.08-hotspot
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_242-b08
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\rmishra\.IntelliJIdea2019.1\system\tomcat\Unnamed_goetldashboard_2
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\ETLProduct\Tomcat-9.0.12
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jvmhook
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\rmishra\.IntelliJIdea2019.1\system\tomcat\Unnamed_goetldashboard_2\conf\logging.properties
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\rmishra\.IntelliJIdea2019.1\system\tomcat\Unnamed_goetldashboard_2\jmxremote.password
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\rmishra\.IntelliJIdea2019.1\system\tomcat\Unnamed_goetldashboard_2\jmxremote.access
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\rmishra\.IntelliJIdea2019.1\system\tomcat\Unnamed_goetldashboard_2
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\ETLProduct\Tomcat-9.0.12
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\ETLProduct\Tomcat-9.0.12\temp
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xrunjvmhook
    INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xbootclasspath/a:C:\Program Files (x86)\Micro Focus\Unified Functional Testing\bin\java_shared\classes\jasmine.jar
    INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler [“http-nio-8080”]
    INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
    INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler [“ajp-nio-8009”]
    INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
    INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 728 ms
    INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
    INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.12
    INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [“http-nio-8080”]
    INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [“ajp-nio-8009”]
    INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 55 ms

    Reply
  2. i don’t see Tomcat in the list Add new configuration in Intellij Ultimate 2019.2 version how can i fix this problem? Pls help me

    Reply
  3. Thanks! I haven’t seen the first step on any other site, so you saved me a lot of nerves!

    Reply
  4. Hola @mkyong tengo un problema con la version 11.0.4 Community 2019, me sale este error al ejecutarlo:
    Error running ‘Tomcat’: org.xml.sax.SAXParseException

    Reply
  5. Thanks, you saved my a lot of trouble finding. More clear even than the Jetbrains docs. Keep up the good work 🙂

    Reply
  6. How about run/debug using remote tomcat app server configurations instead of local??? Any help would be appreciated. Thank you.

    Reply
  7. in community edition i cant find find this tomcat and tomEE integration , can i do this via intellij idea community edition ???

    Reply
  8. Jesus fucking criest.
    That’s all I have to say.
    Nothing more, nothing less.
    It’s been 5 days, I am trying to connect Tomcat9 server with IntelliJ Ultimate 2019.1.3 in Ubuntu 19.04,
    asked everywhere, Reddit, Askubuntu, ubuntuforms, etc even in IntelliJ community.
    After solving many other issues, in 5th day, a dev from IntelliJ community recommended this webpage.

    Thanks to him and that’s to u for creating this article. Now I can die peacefully.

    Reply
  9. I get this error message:
    error running ‘Tomcat 8’:
    port out of range:-1
    Does anyone know what might be the problem?

    Reply
    1. I’ve the same problem on Ubuntu with Tomcat9 (installed by apt).
      With Tomcat8 works well.
      I would like know what is the origin of this problem.

      Reply
  10. You are my spirit animal, thank you. Finally without any remote server involved – easy solution.

    Reply
  11. Thanks, better than Jetbrains docs.

    Reply
      1. Hey please i don’t see Tomcat in the list Add new configuration

        Reply
        1. Am experiencing the same issue. @mkyong please help.

          Reply
  12. Is this applicable for only Ultimate Edition only?

    Reply
      1. I think this plugin you used in your tutorial got removed, I don’t see it in my Ultimate IDEA.
        But “Smart Tomcat” did the job just fine.

        Reply
      2. You should add that to the beginning of your article : )

        Reply

Leave a Comment

Your email address will not be published. Required fields are marked *