Tomcat startup ignoring jpda option for debug

clairebones picture clairebones · Sep 10, 2013 · Viewed 18.2k times · Source

I am attempting to run Tomcat 7 in debug mode. If I type ./catalina.sh jpda start tomcat runs as though the jpda option is not there and outputs:

Michaels-MacBook-Pro:bin clairewilgar$ ./catalina.sh jpda start
Using CATALINA_BASE:   /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS
Using CATALINA_HOME:   /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS
Using CATALINA_TMPDIR: /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS/temp
Using JRE_HOME:        /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH:       /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS/bin/bootstrap.jar:/Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS/bin/tomcat-juli.jar

and does not change my CATALINA_OPTS or anything. If I attempt to connect via Eclipse I get the error

'Launching workflow' has encountered a problem. Failed to connect to remote VM. Connection refused.

I have tried changing the port to jpda port to 8001 to no success, I have tried declaring the JPDA options in the terminal before calling catalina.sh but that makes no difference. My catalina.sh JPDA lines are as follows:

if [ "$1" = "jpda" ] ; then
  if [ -z "$JPDA_TRANSPORT" ]; then
    JPDA_TRANSPORT="dt_socket"
  fi
  if [ -z "$JPDA_ADDRESS" ]; then
    JPDA_ADDRESS="8000"
  fi
  if [ -z "$JPDA_SUSPEND" ]; then
    JPDA_SUSPEND="n"
  fi
  if [ -z "$JPDA_OPTS" ]; then
    JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
  fi
  CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS"
  shift
fi

Are there any other reasons why JPDA might not run? I'm using OSX (Mountain Lion) if there's anything related to that that I may have missed. Thanks in advance.

EDIT: My catalina.out file for running ./catalina.sh jpda start is at http://pastebin.com/Z4GSvckr

Answer

Qben picture Qben · Sep 10, 2013

Same issue if you start it from startup.sh? Remeber you might have to edit startup.sh to make it call catalina.sh with the jpda parameter.

Have you tried to set the variables manually? I never had this issue at my end but I tend to do something like described in this wiki.

Also, if the variables above are already set in your environment they will not be reset in the catalina.sh script (-z).

You could also try to add setup.sh in the bin folder containing:

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

With this change you can simply start tomcat using startup.sh start.