Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP debugging in IntelliJ IDEA using the Tomcat Maven Plugin

We used to have Tomcat run configuration in IntelliJ. This deployed our webapp to a locally installed tomcat instance, and let us debug both java classes and jsp files.

Now we've made the switch to Maven, and we now run our Tomcat instance using the tomcat7 maven plugin with the maven goal: tomcat7:run-war

Debugging our java classes works perfectly, however (due to large amounts of legacy code) we also need to be able to debug JSP files.

Is it possible to debug JSPs in IntelliJ when an embedded Tomcat is launched from the maven plugin?

like image 802
Michiel Avatar asked Nov 12 '22 02:11

Michiel


1 Answers

It is indeed possible. You need to run the Tomcat plugin with some extra configuration and then connect to it like it was a remote Tomcat instance.

Create a Remote Debug Run Configuration

  1. Click "Run" then "Edit Configurations"
  2. Click "Add New Configuration" (a green plus symbol), then "Tomcat Server", then "Remote".
  3. Give the configuration a sensible name e.g. JSP Debug.
  4. Untick "After launch".
  5. Make sure the remote connection port is correct (8080 should be fine but you may have configured this differently with the plugin).
  6. Switch to the "Startup/Connection" tab and select "Debug". Look at the configuration line it gives you and copy this. You will need this in the next step.

Create a Maven Tomcat Plugin Run Configuration

  1. Click "Add New Configuration" (a green plus symbol), then "Maven".
  2. Give the configuration a sensible name e.g. "Run".
  3. For "Command line" enter "tomcat6:run-war" or "tomcat7:run-war" depending on the version of Tomcat you have setup.
  4. Switch to the "Runner" tab and paste in the line you copied earlier into "VM Options".
  5. Click "OK".

Usage

  1. First run the Maven Tomcat Plugin Configuration. Make sure you do not debug it or IntelliJ will override the configuration you have setup for it.
  2. Then debug the Remote Debug Configuration. This should connect to the currently running Tomcat.
  3. Put a break point in a JSP and load a page to trigger the break point.
like image 109
Rupert Madden-Abbott Avatar answered Nov 14 '22 23:11

Rupert Madden-Abbott