Setting up IntelliJ and Tomcat for Debugging Sakai
IntelliJ IDEA 2020.2.3
Tomcat 8.5.59
Sakai 20.x
Prerequisite: Having Sakai Source Code cloned to local Repository and a Tomcat working with deployed sakai
Configure IntelliJ
Got to: Run → Edit Configuration
then add a new remote: + → Tomcat Server → Remote
> Server Tab
>> choose your Application Server: Application Server → Configure → choose your Tomcat Container deployed sakai to (e.g. /opt/apache-tomcat-8.5.46)
>> Remote Connection Settings → Port: 8000 (has to match port set under Startup/Connection → Debug)
> Startup/Connection Tab
>> select Debug
>> Copy the String (e.g. "-agentlib:jdwp=transport=dt_socket,address=8000,suspend=y,server=y -javaagent: .../.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/202.7660.26/plugins/Groovy/lib/agent/gragent.jar")
Configure Tomcat
create a file setenv.sh at $CATALINA_HOME/conf/setenv.sh and assign the string from IntelliJ to JPDA_OPTS environment variable
setenv.sh
export JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,suspend=y,server=y -javaagent: .../.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/202.7660.26/plugins/Groovy/lib/agent/gragent.jar"
Start Tomcat in Debug Mode
e.g. with Terminal
Start Tomcat in Debug Mode
user@machine: /opt/apache-tomcat-8.5.46$ bin/catalina.sh jpda runYou will see tomcat listening to Port 8000 then.
Start Debugging in Intellij
Run → Debug (or press Debug button on the right top corner)
That's it!
Now you should see the tomcat logs starting up sakai. Feel free to set breakpoints in Intellij