how to start tomcat debug port in windows while debugging tomcat application

13,222

Solution 1

Basic config is: In catalina.bat under tomcat/bin file modify the below.

  1. CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
  2. JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
  3. Run Tomcat from command prompt: catalina.sh jpda start

Then in eclipse create a debug configuration:

  • Write any name for the configuration.
  • Write the project name.
  • Write the connection type as Standard(Socket Attach)
  • Host should be localhost
  • Port as 8000( or any port number, but that should be the same in other places also).

see: Remote debugging Tomcat with Eclipse

Solution 2

When run as windows service, Tomcat's command line options could be stored in registry at HKLM\Software\Wow6432Node\Apache Software Foundation\Procrun 2.0\TomcatServiceName path for 64-bit OS and at HKEY_LOCAL_MACHINE\Software\Apache Software Foundation\Procrun 2.0\tomcat8 for 32-bit.

See Where does Tomcat7w.exe store Settings on Windows.

Those settings can be viewed and changed via running bin\tomcatw.exe.

Share:
13,222
ThinkTank
Author by

ThinkTank

By Day: I will be available but I am not answering that means I am in the different timezone. By Night: I sleep like the hog. Interests: Learning new things which keeps me updated, and love mountains and trekking.

Updated on June 28, 2022

Comments

  • ThinkTank
    ThinkTank about 2 years

    I'm getting Exception while debugging

    Failed to connect to remote VM. Connection refused.
    Connection refused: connect.
    

    i have tried command in windows system

    netstat -n -a -p tcp

    but my port 8787 was not there how to start that port.

  • ThinkTank
    ThinkTank about 8 years
    by default eclipse is taking 1043 as a port now. how i don't know?? when i am trying to do with eclipse UI but now it is taking default port where it is defined?
  • KlajdPaja
    KlajdPaja about 8 years
    No one else has given a hint so I'll give a shot by searching for JPDA_OPTS in all .bat files inside bin but it should be in catalina.bat or setenv.bat
  • ThinkTank
    ThinkTank about 8 years
    dt_socket port is by default at startup 1043 how please help me. while manually starting tomcat 7.
  • KlajdPaja
    KlajdPaja about 8 years
    If you start it manually specify the port like this, in windows: bin\startup.bat -debug 8000
  • ThinkTank
    ThinkTank about 8 years
    then i get socket error but after configuring in eclipse port number 1043. when manually starting it takes 1043 as port number.
  • KlajdPaja
    KlajdPaja about 8 years
    well that might be because the port is being used by another process, so try another port or kill that process
  • ThinkTank
    ThinkTank about 8 years
    after using telnet i am not able see that port also
  • ThinkTank
    ThinkTank over 7 years
    Thanks,I have changes in catalina.bat also seen many options such as -Xmx,-XX:PermSize etc thanks again.