Published on Jul 2 2015 in Java Tomcat

The 'jpda' option in Apache Tomcat will not work if you use it with startup.sh (like startup.sh jpda or js jpda). You need to use 'catalina.sh jpda start instead.

If you want to use startup.sh you may modify last line of startup.sh to read

exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"

instead of

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

But it is dirty hack as it modifies core file so we recommend using setenv.sh where you can place your custom settings.

Add into the file (create it if missing):

JPDA_TRANSPORT="dt_socket"
JPDA_ADDRESS="_YOUR_CUSTOM_PORT_HERE_"
JPDA_SUSPEND="n"
JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS"

Note the custom port that is needed when you run private JVM on shared server to avoid port conflict. Find a free (unused) port in Java Control Panel - Ports or request another one from us. When on VPS or dedicated server with single JPDA enabled JVM you can use the default value of 8000.

Now you can use startup.sh or js alias like you did before. The difference is JPDA will now be always active. catalina.sh jpda start will still work as expected and it will pickup your settings defined in bin/setenv.sh.

Note JPDA (Java Platform Debugger Architecture) is for debugging and JMX for monitoring. Both can run in parallel and JMX can be enabled in Java Control Panel - JMX. JMX URL, username and password will be displayed there for you.

Find more on debugging using JPDA with Eclipse or NetBeans in Tomcat's Wiki.