Tomcat startup ignoring jpda option for debug

19.1k views Asked by At

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

5

There are 5 answers

13
Qben On

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.

0
borowis On

I had the same problem, as it turned out my startup.sh file contained the following lines:

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

Therefore command ./startup.sh jpda start was sent to catalina.sh as start jpda start and therefore debugging options were ignored, so I had to change this line to

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

Regards, Borys

0
Eyal leshem On

you can change this line in the catlina.sh:

if [ -z "$JPDA_SUSPEND" ]; then
    JPDA_SUSPEND="n"
fi

to :

if [ -z "$JPDA_SUSPEND" ]; then
    JPDA_SUSPEND="y"
fi

or set the env-var "JPDA_SUSPEND" to "y" - before calling the catalina.sh

0
jcarlosriveraavila On

Change the last line of this file: "startup.sh" ("startup.bat" if you are using Windows)

Instead of using this:

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

Use this:

exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"
0
Titi Wangsa Bin Damhore On

It may be an IPv4 vs IPv6 issue.

netstat -an | grep 8000

I once had a problem where I could not connect to "localhost" port 13306, but could connect to "127.0.0.1" port 13306

localhost was mapped to an IPv6 address while the process was listening to an IPv4 address