9

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

clairebones
  • 225
  • 1
  • 3
  • 6

5 Answers5

6

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.

Qben
  • 2,617
  • 2
  • 24
  • 36
  • Same issue yeah, I had looked at that wiki previously but it doesn't seem to make any difference. Tried to set the variables manually too, but somehow still ignores it and just runs normal Tomcat. – clairebones Sep 10 '13 at 13:00
  • It seems to be exactly the same as it would be if I weren't calling jpda, doesn't mention it or jdwp and no errors. See here: http://pastebin.com/Z4GSvckr – clairebones Sep 10 '13 at 13:31
  • I just downloaded `tomcat 7.0.42` (Windows x86, executed in cygwin) and it works fine. Both with `jpda start` and setting the env variables in `setup.sh` and just start it with `startup.sh start`. Does a vanilla tomcat work for you? Nothing additional deployed. – Qben Sep 11 '13 at 06:51
  • Hmm, vanilla (no WARS or anything) deploys ever time, but it doesn't call jpda either... I checked the firewall and there was nothing there stopping it, so not sure what else could be doing it. – clairebones Sep 11 '13 at 08:21
  • Could you try to add `echo $CATALINA_OPTS` before starting the JVM in `catalina.sh` (around row 386 i believe) and see what it says? – Qben Sep 11 '13 at 08:27
  • My CATALINA_OPTS just says `-Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true` – clairebones Sep 11 '13 at 08:59
  • I would go for the `setenv.sh` solution and set my variables in there unless you tested it? It's really odd you don't get the JPDA option in your output. Unfortunately I don't have access to a mac to test this on. – Qben Sep 11 '13 at 09:05
  • I just tried using setenv and that doesn't seem to work either. I even put the variables in my bash_profile at one point to see if that helped. – clairebones Sep 11 '13 at 09:30
  • Could you provide what you wrote in it, and also where you put it? I am running out of ideas. Something is really fishy in your environment I believe. :-) – Qben Sep 11 '13 at 09:37
  • It simply contains #Catalina CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true" TOMCAT_HOME="/Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS/bin/" # Eclipse Debugging JPDA_TRANSPORT=dt_socket; export JPDA_TRANSPORT JPDA_ADDRESS=8000; export JPDA_ADDRESS and is in the bin folder alongside catalina.sh. At this point I have no idea why it doesn't work... – clairebones Sep 11 '13 at 09:44
  • I added my `setup.sh` in the reply since it's easier to read. – Qben Sep 11 '13 at 09:50
  • That didn't work either... Still no jdpa/jdwp mention and eclipse still can't connect. – clairebones Sep 11 '13 at 11:18
  • This thread was also never solved, http://stackoverflow.com/questions/13068046/cant-start-tomcat7-debug-mode-on-macos?rq=1 I am unfortunately out of ideas without a test system. – Qben Sep 11 '13 at 12:02
1

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

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
0

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

Eyal leshem
  • 995
  • 2
  • 10
  • 21
0

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

borowis
  • 1,207
  • 10
  • 17
0

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 "$@"
philburns
  • 310
  • 4
  • 18