Search code examples
javatomcatremote-debuggingcatalina

Error during starting tomcat in remote debug mode


Tomcat is not starting in debug mode. Getting below logs.

C:\ApacheSoft\apache-tomcat-7.0.67\bin>catalina.bat jpda start
Using CATALINA_BASE:   "C:\ApacheSoft\apache-tomcat-7.0.67"
Using CATALINA_HOME:   "C:\ApacheSoft\apache-tomcat-7.0.67"
Using CATALINA_TMPDIR: "C:\ApacheSoft\apache-tomcat-7.0.67\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.7.0_79"
Using CLASSPATH:       "C:\ApacheSoft\apache-tomcat-7.0.67\bin\bootstrap.jar;C:\ApacheSoft\apache-tomcat-7.0.67\bin\tomcat-juli.jar"
=transport=dt_socket was unexpected at this time.

Solution

  • Let me guess, you read a link called "HOW TO REMOTELY DEBUG APPLICATION RUNNING ON TOMCAT FROM WITHIN INTELLIJ IDEA" on blog.trifork.com.

    The instructions say to do this for Windows in your setenv.bat:

    set JPDA_OPTS="-agentlib:jdwp=transport=dt_socket, address=1043, server=y, suspend=n"
    

    Yeah, that's not going to work. catalina.bat adds its own quotes, so it winds up trying to do this:

    if not ""-agentlib:jdwp=transport=dt_socket, address=1043, server=y, suspend=n"" == "" goto gotJpdaOpts
    

    A better plan is to do this:

    set JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,address=1043,server=y,suspend=n
    

    I know this is from almost a year ago, but I ran into this, and ultimately had to remove "@echo off" from the Tomcat batch files and chase this down myself. Hopefully, this will get voted up so that it can save someone else this grief.