1

I need to build and debug tomcat in intellij. I have tried a number of guides as noted below without much success.

System Variables:

  • ANT_HOME = C:\Users\User1\Desktop\Tomcat\apache-ant-1.10.9
  • CATALINA_HOME = C:\Users\User1\Desktop\Tomcat\apache-tomcat-9.0.41
  • JAVA_HOME = C:\Program Files\Java\jdk1.8.0_281
  • PATH: ...;%JAVA_HOME%\bin;%ANT_HOME%\bin;%CATALINA_HOME%\bin

File Paths:

  • C:\Users\User1\Desktop\Tomcat\apache-ant-1.10.9
  • C:\Users\User1\Desktop\Tomcat\apache-tomcat-9.0.41
  • C:\Users\User1\Desktop\Tomcat\apache-tomcat-9.0.41-src

Intellij Version: 2020.3.1

Possible solution (LINK) but how would you open up the project and how would you configure the run/debug? I believe this would work but I need a step-by-step guide on how to open this in intellij and how it can be built and debugged.

cd apache-tomcat-9.0.41-src
ant -buildfile build.xml ide-intellij

Alternative solutions but appear outdated:

RazorWing
  • 35
  • 1
  • 6

1 Answers1

1

how would you open up the project

To open the project you should be able to just use File | Open action in Intellij IDEA after running the ant -buildfile build.xml ide-intellij.

how would you configure the run/debug?

Use steps from RUNNING.txt to set up teh all the environment variables and in Tomcat startup script catalina.sh script right above the first line that reverences the JAVA_OPTS variable, add this line:

JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=64998"

Now, restart Tomcat. Next, in IntelliJ, create a Remote JVM Debug Run/Debug Configuration, enter the port just like in the command line (64998), save it and then press "Debug" in IDE

enter image description here

Andrey
  • 15,144
  • 25
  • 91
  • 187
Petre Popescu
  • 1,950
  • 3
  • 24
  • 38
  • I have added the JAVA_OPTS line at 265 of "catalina.sh" file which is the first reference to the variable inside "apache-tomcat-9.0.41-src\bin". I then ran "startup.bat", then in IntelliJ, I created the new configuration ([Image](https://imgur.com/rn3xp6Z)), then clicked "Debug" icon next to "debug-tomcat-9" which produces "Unable to open debugger port" ([Image](https://imgur.com/mbLhHGd)). I have changed the port number on both sides to something else and this doesnt work either. Anything I am missing? – RazorWing Jan 20 '21 at 14:08
  • I have updated the answer. Make sure you have set up all environment variables as specificd in Tomcat `RUNNINT.txt` documentation and started the Tomcat startup script with needed JVM options for the remote debug - make sure you have set the correct JDK version in Remote Debug Configuration. See also this example for starting Tomact server with remote debug JVM options: https://stackoverflow.com/a/6734028/2000323 – Andrey Jan 21 '21 at 09:45
  • @Andrey Thank you for clarifying. I went through the Running.txt as suggested but I am still receiving the same error. Here are the steps I taken to configure on a fresh install of Windows today right up until I receive the error: [Link](https://imgur.com/a/LHYzRw9) – RazorWing Jan 21 '21 at 21:43