自由之思想，独立之精神

Tomcat Debugging With IntelliJ IDEA Community Edition

In Eclipse EE edition, there is support to debugging web application with web container implementation like Tomcat. IntelliJ IDEA professional edtion seems have the same function. However, in IntelliJ IDEA community edition, how to do it?

Note the “address=9999” means the network port number used by Tomcat for debugging.

Second, open IntelliJ IDEA community edition, go to “Run -> Edit Configurations”, click the “+” icon and select “Remote” from the list, then you will see a dialog like below:

Note that you only need to update the “Port:” field and the “Search sources using module’s classpath:” list, the “Command line arguments for running remote JVM” will be changed accordingly as you update the “Port” field and does not need manually update.

In the “Port:” field, just write “9999” as you set in the “bin/catalina.sh” file. In the “Search sources using module’s classpath:” list, select you project which will running in Tomcat. And remember to give a name like “Tomcat” for this “run/debug configuration” item.

Third, configure Tomcat to use the project built files as the web application context. To do so, you need to create a “${TOMCAT_HOME}/conf/Catalina/localhost/ROOT.xml” file under the Tomcat installation directory:

Now, you just need to start Tomcat as usual(run “./bin/startup.sh”), then in IntelliJ IDEA, open “Run -> Debug ‘Tomcat’”. If everything works, you will see the following output in the “Console” tab in the “Debug” tool window: