3

I'm transitioning from Eclipse to IntelliJ Idea and having some trouble getting my Maven Web project running as I'd like. In Eclipse, I ran it using mvn tomcat:run, which worked fine with JSP debugging. In IntelliJ, I created a run configuration to use this command, and it works, but JSP debugging doesn't work.

I tried to find info on getting JSP debugging to work on IntelliJ, and the only info I found involved setting up a Tomcat server in IntelliJ, not using Maven's tomcat with mvn tomcat:run. The problem is, I can't figure out how to do this without IntelliJ using it's own builder instead of building the project with Maven. I can add Maven goals like "mvn compile", but when I set it to deploy exploded war, and adds 'build myproject:war exploded artifact' to the build queue, which calls IntelliJ's builder.

IntelliJ's builder takes forever to build my project. I've never even let it finish. To be fair, the project is huge, but Maven builds to fairly quickly. Also, everyone in my company is using Maven to build it, so I need to use Maven as well.

Can anyone help me either get JSP debugging working using mvn tomcat:run, or on an Intellij managed Tomcat with the project built by Maven?

Angularjsguy
  • 29
  • 1
  • 1
  • 10
Sarevok
  • 437
  • 1
  • 7
  • 20

1 Answers1

4

In IntelliJ you can easily debug a "remote" tomcat instance (one running in a different JVM than IntelliJ):

Run -> Edit Configuration -> "+" -> Tomcat Server -> Remote 

That will create a new run configuration. Look at the information on the "Startup/Connection" tab for the parameters to add to the tomcat JVM. Mine are:

-Xdebug -Xrunjdwp:transport=dt_socket,address=57813,suspend=n,server=y

Finally, start tomcat by launching the required maven command. Then run the above run configuration (click debug button).

Keith
  • 4,144
  • 1
  • 19
  • 14
  • Thanks, that worked. It would be nice not to have to run it from the command prompt all the time though. I tried doing this by creating a Maven run configuration that runs tomcat7:run and put the debug args you posted in the VM options (not sure where else to put them). Once that was up and running I tried running the remote tomcat server config, but it said it was unable to connect on that port. Any ideas? – Sarevok Sep 23 '13 at 17:39
  • Ultimately you need to pass "-Xdebug" and related parameters to the JVM on which tomcat will run. Ideally the tomcat-maven-plugin would document how to do this, since it is responsible for starting that JVM, but I don's see it mentioned in the docs. This answer has a suggestion, but at least two commentators say it didn't work for them: http://stackoverflow.com/questions/11928689/increase-memory-of-tomcat7-maven-plugin Of course you could always abandon the idea of starting tomcat from maven and just start it from IntelliJ (local tomcat), at least when debugging. – Keith Sep 23 '13 at 20:20