3

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.

Alex K
  • 22,315
  • 19
  • 108
  • 236
ThinkTank
  • 1,737
  • 5
  • 22
  • 36

2 Answers2

3

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

KlajdPaja
  • 959
  • 1
  • 8
  • 17
  • 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? – ThinkTank May 25 '16 at 12:39
  • 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 – KlajdPaja May 25 '16 at 14:16
  • dt_socket port is by default at startup 1043 how please help me. while manually starting tomcat 7. – ThinkTank May 27 '16 at 05:51
  • If you start it manually specify the port like this, in windows: `bin\startup.bat -debug 8000` – KlajdPaja May 27 '16 at 07:56
  • then i get socket error but after configuring in eclipse port number 1043. when manually starting it takes 1043 as port number. – ThinkTank May 27 '16 at 10:28
  • well that might be because the port is being used by another process, so try another port or kill that process – KlajdPaja May 27 '16 at 10:29
  • after using telnet i am not able see that port also – ThinkTank May 27 '16 at 10:54
  • Thanks,I have changes in catalina.bat also seen many options such as `-Xmx,-XX:PermSize` etc thanks again. – ThinkTank Feb 09 '17 at 05:25
1

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.

Community
  • 1
  • 1
Vadzim
  • 24,954
  • 11
  • 143
  • 151