Tomcat startup ignoring jpda option for debug
Asked Answered
V

5

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

Vivl answered 10/9, 2013 at 11:32 Comment(0)
T
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.

Transilluminate answered 10/9, 2013 at 11:54 Comment(13)
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.Vivl
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: pastebin.com/Z4GSvckrVivl
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.Transilluminate
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.Vivl
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?Transilluminate
My CATALINA_OPTS just says -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=trueVivl
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.Transilluminate
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.Vivl
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. :-)Transilluminate
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...Vivl
I added my setup.sh in the reply since it's easier to read.Transilluminate
That didn't work either... Still no jdpa/jdwp mention and eclipse still can't connect.Vivl
This thread was also never solved, #13068546 I am unfortunately out of ideas without a test system.Transilluminate
G
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

Gastrology answered 19/9, 2013 at 9:58 Comment(0)
O
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

Operable answered 10/6, 2014 at 10:42 Comment(0)
A
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

Alvinia answered 24/7, 2014 at 9:46 Comment(0)
V
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 "$@"
Vinitavinn answered 11/9, 2014 at 10:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.