I need to directly debug on the application Tomcat server, not only on my local Tomcat instance.
Compile Java code
For debugging we need to keep the line numbers while compiling.
To build the war file we use an ANT script and we have to add the debug and debuglevel attributes in the javac tag:
<javac srcdir="${src}" destdir="${build}" includeantruntime="false" encoding="UTF-8" source="1.8" fork="true" debug="on" debuglevel="lines,vars,source" verbose="true"> [...] </javac>
Configure Tomcat server
To enable remote debugging on the Tomcat server add some arguments to CATALINA_OPTS in setenv.sh file:
ATALINA_HOME=/app/myApp/tomcat CATALINA_BASE=/app/myApp/tomcat CATALINA_PID=/app/myApp/tomcat/tomcat.pid JAVA_HOME=/app/java/jdk8u265-b01-jre CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/app/library -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/library export LD_LIBRARY_PATH JAVA_OPTS="${JAVA_OPTS} -Djavax.net.ssl.trustStore=/app/certs/corporate_truststore.jks -Djavax.net.ssl.trustStorePassword=secret -Xms256M -Xmx1024M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/app/myApp/dump"
Configure Eclipse
Create a new debug configuration: