I am trying to connect to JBoss eap 6.4 remotely using Eclipse for remote debugging purpose.
I have modified the following lines in "standalone.bat"
rem JBoss Bootstrap Script for Windows
rem -------------------------------------------------------------------------
rem Use --debug to activate debug mode with an optional argument to specify the port
rem Usage : standalone.bat --debug
rem standalone.bat --debug 9797
rem By default debug mode is disable.
set DEBUG_MODE=true
set DEBUG_PORT=8787
I have also modified the following line(just uncommented) in "standalone.conf.bat" file:
rem # Sample JPDA settings for remote socket debugging
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
I am getting the following error when I try to connect JBoss server remotely:
Failed to connect to remote VM. Connection refused.
Connection refused: connect
Can anybody tell me how to fix this issue?
Doublecheck that the host used on connection properties is the one jboss binds to (e.g. via jboss.bind.adress)
Check if JBoss-VM is really listening on the port 8787 (e.g. netstat /a)
Check that no firewall comes in between.
I've got a server running on DigitalOcean and a JAR file that I want to debug. I first start the JAR on the remote server using
java -jar Server.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
but on the console I see no output like "listening on port 5005...".
When I press debug in IntelliJ it says
unable to open debugger port (198.xxx.xxx.xx:5005):
java.net.ConnectException "Connection refused"
This is my IntelliJ configuration:
I also tried using -Xdebug but it still didn't work.
If I set suspend=y it should wait until a debugger is connected, but instead, it starts without problems.
The command to start the remote Java process in debug mode looks correct. If you don't see "Listening to Port blah" when you start the server JAR, then it might mean that the debug args are not being picked up. Another way to quickly check this would be to test with a telnet localhost 5005 on the machine where the server JAR is being executed. The telnet will fail if that port is not being used.
I suggest that you try the following, since the order of the parameters might be significant (I'll add some official evidence for this later):
java "agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" -jar Server.jar
this command worked for me:
export JAVA_OPTS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005'
by default idea remote dialog suggest:
'agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'
change it to:
'agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005'
and issues port 5005.
This command worked for me:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar Server.jar
Thanks to suifengpiao14 but I'm going to describe the problem a bit more in detail.
I checked multiple things, and at the end found the reason: actually as like as a restful service we want to be accessible from out of the server we are running it that we should set 0.0.0.0 as the nameserver, here we should do a similar one.
I checked the difference between the server from which I can remotely debug and the one which I can't. using netstat command:
for the server which I was ok with:
tcp 0 0 0.0.0.0:5005 0.0.0.0:* LISTEN 8323/java
for the server which I had problem with:
tcp 0 0 127.0.0.1:5005 0.0.0.0:* LISTEN 8323/java
So, using below jvm options should be helpful:
'agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005'
'agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005'
In my case it was because under settings -> build, execution, deployment -> debugger I had a built in server running on the same port as which I was trying to attach my debugger to for some reason.
For people like me who sometimes forget to read...
Copy and paste the arguments to the command line when JVM is started
says the Run/Debug Configuration in IntelliJ, directly under:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
Means:
Copy this line and go to your docker configuration. Add an environment variable (modify options dropdown). Paste it there with JAVA_OPTS= prepended.
Now when you did every correctly, you will have
Listening for transport dt_socket at address: 5005
and
Command line argument: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
This is who I solved it...
I've reproduced similar issue:
Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused (Connection refused)"
I had it while running debugger w/ command line arguments for remote JVM using Run/Debug configurations:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
by attaching IDE with exposed debug agent server.
Since I've used Kubernetes cluster, the reason was:
once the pod has been created and was running as expected, I needed to proceed to set up port forwarding with the kubectl port-forward command, with the port to expose locally for traffic from the application before running debugger.
Based on kubectl port-forward syntax:
kubectl port-forward <resource-type/resource-name> [local_port]:<pod_port>
In format like:
kubectl port-forward <pod-name> -n <namespace> 5005:5005
or in a shorter form:
kubectl port-forward <pod-name> 5005:5005
The client listens on port 5000 locally and forwards to 5000 in the
pod.
Accordingly entrypoint.sh file of the service was configured w/ the following command for Kubernetes cluster:
java -Djava.security.egd.=file:/dev/./urandom -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -Xmx400m -jar /service.jar
As result, running port-forward before debugger solved the issue.
One of the reason is that the port is not enabled. You can try by enabling the port using the below command
firewall-cmd --zone=public --permanent --add-port=8001/tcp
Once the port is up, restart tomcat & try connecting again.
Hope it helps.
This might help someone That port in JVM debug is not your web app port
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.
Basic config is:
In catalina.bat under tomcat/bin file modify the below.
CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
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
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.
To remotely debug my application running in tomcat7 over ubuntu server I set the following variables;
export CATALINA_HOME=/usr/share/tomcat7
export CATALINA_BASE=/var/lib/tomcat7/
export JPDA_ADDRESS=8090
export JRE_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
then I went to tomcat home folder /usr/share/tomcat7/bin and write the following line to run tomcat in debug mode.
\#./catalina.sh jpda start
then I try to remotely connect, I got Connection Refused. I checked with netstat -ln both 80 and 8090 ports were listening, then I stop tomcat using service tomcat7 stop , then my 80 port stops listening and I was able to remotely connect as well.
As a learner I need to know what is the reason of this? Is that something like 2 jvm started one with debugger and one simple and doing some confusion ? but I have it on another port why I am unable to connect to that?
The purpose is to:
connect to a remote server maybe via host: ip , port: 8181
stop Tomcat that's running on that server
deploy a .war file
restart Tomcat
Underneath are few approaches I have taken so far to achieve this task:
Approaches taken so far:
I have looked at the following solutions but none of them worked for me:
http://www.linuxquestions.org/questions/linux-newbie-8/start-tomcat-server-remotely-824472/ --Not efficient
http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Start_an_Existing_Application
http://raibledesigns.com/wiki/Wiki.jsp?page=TomcatAntTasks
--only start/stop application not the actual tomcat itself
http://cargo.codehaus.org/Remote+Container
-- Which does't start/stop tomcat that's running on that server
If you have ssh access to the server, then you might like to consider the JSch library which you can use in combination with SSHExec Ant Task to start and stop your server:
<sshexec host="somehost"
username="dude"
password="yo"
command="/etc/init.d/tomcat restart"/>
For start/stop tomcat
In linux environment
use SSH to reach the terminal of the remote machine.
from the terminal You can start/stop the tomcat
to start startup.sh
to stop shutdown.sh
Under windows environment
Install OpenSSHD for Windows - this will allow remote "console" sessions.
If you looking for something very "unix-like" then you can install cygwin.
http://www.worldgoneweb.com/2011/installing-openssh-on-windows-7/
to start startup.bat
to stop shutdown.bat
For deployment
Simply go to tomcat manager link on the below page(on any environment)
http://your_server_ip:port_number/
user credential are specified in tomcat-users.xml inside conf di