Tomcat startup ignoring jpda option for debug

18,198

Solution 1

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.

Solution 2

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

Share:
18,198
clairebones
Author by

clairebones

Updated on July 26, 2022

Comments

  • clairebones
    clairebones almost 2 years

    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
    clairebones over 10 years
    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
    clairebones over 10 years
    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/Z4GSvckr
  • Qben
    Qben over 10 years
    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.
  • clairebones
    clairebones over 10 years
    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.
  • Qben
    Qben over 10 years
    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?
  • clairebones
    clairebones over 10 years
    My CATALINA_OPTS just says -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true
  • Qben
    Qben over 10 years
    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.
  • clairebones
    clairebones over 10 years
    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.
  • Qben
    Qben over 10 years
    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. :-)
  • clairebones
    clairebones over 10 years
    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...
  • Qben
    Qben over 10 years
    I added my setup.sh in the reply since it's easier to read.
  • clairebones
    clairebones over 10 years
    That didn't work either... Still no jdpa/jdwp mention and eclipse still can't connect.
  • Qben
    Qben over 10 years
    This thread was also never solved, stackoverflow.com/questions/13068046/… I am unfortunately out of ideas without a test system.