Debugger failing to attach - java

I'm trying to remote debug a Tomcat. I added -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 to JAVA_OPTS and restarted Tomcat. IntelliJ wasn't able to attach. So I tried telnet thehost 5005 and it seemed I was initially attached but then my session was terminated with Connection closed by foreign host and catalina.out had Debugger failed to attach: timeout during handshake. Same thing happened if I did telnet localhost 5005 on the remote machine.
If I do netstat -antp | grep 5005 on the remote machine I get
tcp 0 0 0.0.0.0:5005 0.0.0.0:* LISTEN 26745/java-tomcat12
So it seems the JVM is listening. What am I doing wrong?
Update: using the same options I can debug a very simple hello world like application which I run on the remote server. So it seems it's something specific to Tomcat, or at least this specific web application.

Related

Open a port on VMWare Player: Connection Refused error

I need to open a port on a VMWare Player VM but getting Connection Refused error.
(I have read many other Q&A on same, but many of them focus on VMWare workstation.)
Scenario:
I need to remote debug a Java application running inside a VM.
Host OS and VM OS are both Ubuntu.
I can access Webserver running inside VM via browser, using https. Which mean 8443 is open on VM. For this I didn't have to do anything.
Now, I have my code in IntelliJIdea running on host. I want to attach the debugger to process running inside guest VM. I have tried to open port 6006 and 8998.
I have ensured:
firewall ufw is inactive in both host and guest
Java app debug port is open. I checked this by running a debugger (jdb) locally on guest. I could connect to Java debug process. But same thing from host OS doesn't work.
What I have tried already:
editing /etc/vmware/vmnet8/nat/nat.conf and restarting vmware process after that.
SSH tunnelling: mapped local port to remote port using
sh -L 6006:<guest_name>:6006 <user>#<guest_name>
In all cases, I keep getting connection refused error.
Appreciate your help in advance.

Eclipse remote debugging stops java to listen on debug port

I have a java application running on remote host started with below:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5555
I can see when application is started it listens on tcp port 5555:
tcp 0 0 0.0.0.0:5555 0.0.0.0:* LISTEN 451357/java
I have allowed this port in iptables. I can connects to this port using telnet.
But whenever I start an eclipse remote debugging it never connects, below is the error:
Failed to connect to remote VM. Connection refused.
Connection refused: connect
I can see in netstat java process stops to listen on 5555 whenever eclipse tries to connect. Anyone faced similar issue?
java version "1.8.0_181"
It was working fine only the eclipse debugger view was not set

Windows server cannot start Apache tomcat due to port 443 is in use and cannot be killed

Hi I cannot start apache tomcat 7.0.77 under my windows server 2012 due to this conflict,
netstat -a -n -o | findstr 443
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 4
TCP [::]:443 [::]:0 LISTENING 4
which I cannot kill by kill the pid due to error:
Error: the proces with PID 4 could not be terminated
reason: access is denied.
I cannot change port in the server config file because another port is not being able to accessed in public. So my only choice is to terminate this conflict and use this port for tomcat.
I have tried to restart the server several times and looking for similar posts in this page.
I really don't know what caused this problem since tomcat used to work fine before. Only when I try to deploy new war file from tomcat gui manager then restart, start, stop apache tomcat service under service manager few times and it keep stopping right after I click start.
Any help please !!
Thank you !
I found out the solution by using process hacker at:
https://processhacker.sourceforge.io/
then go to processes kill that process using that port (note: you can lost remote desktop connection if that is the process related or your server could restart, but after a while all will be back, as for my case).

Tomcat homepage (address:8080) redirects to website homepage

In a server machine A a website (drupal) always run, and now I need to use tomcat (version 5.5 is installed on that machine) to use a webservice.
In another machine (B) where tomcat7 is installed, the address http:// localhost :8080/ shows the tomcat page, but on machine A that address redirect to the drupal website. Does this mean that port 8080 is already used by the website? The command netstat -ntlp | grep LISTEN gives the following output:
...
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1719/apache2
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1719/apache2
...
This means that port 8080 is open and it's already used, right?
Do I have to set tomcat on another port?
Yes. IT seems Apache is using port 8080.
Probably the tomcat on your A machine doesn't even start - check the logs, it should report failure to bind to port.
You can go to server.xml and change the port.

Cannot remotely debug JVM via SSH tunnel

I need to debug a Java application using remote debugger via an SSH tunnel. I configured putty on my PC and I'm able to connect to any other service running on the server using tunnel however eclipse remote debugger fails to connect.
On the server side I use Java 1.6.0_21-b06 started with following debug options:
-Xrunjdwp:transport=dt_socket,address=8686,server=y,suspend=n
On my laptop ssh tunnel is configured as:
L8686 IP_ADDR:8686
Are there any limitations for JVM debugger when running session over ssh tunnel?
One more thing, when I try to connect, on the server console I can see following log mesage:
Listening for transport dt_socket at address: 8686
I have the same scenario and everything is working fine, here is how I run my java app:
java -Xmx120m -agentlib:jdwp=transport=dt_socket,server=y,address=8000 -jar bla.jar
probably the most relevant part is the -agentlib one.
Can you try L8686 localhost:8686 instead, as the JVM may be refusing connections from non-local addresses? Note that 'localhost' is the address from the server's point of view.
That Listening for transport dt_socket at address: 8686 usually occurs if the VM is started or an existing debug session is closed and the VM starts listening for a debug connection again. Maybe running tcpdump on the server could give a clue which peer closes the connection and look a bit deeper on that side.

Categories