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.
Related
I want to attach the Debugger to my deployed WARs in my dockerized WebLogic 12c.
I use this official image of WebLogic (which is a Linux container)
https://hub.docker.com/_/oracle-weblogic-server-12c
and I start the container using docker command:
docker run -d -p 4002:4002 -p 9002:9002
-v c:/my-path-to-shared-volume:/u01/oracle/properties
-e ADMINISTRATION_PORT_ENABLED=true -e DOMAIN_NAME=docker_domain
-e JAVA_TOOL_OPTIONS=\"-agentlib:jdwp=transport=dt_socket,address=4002,server=y,suspend=n\"
--name weblogic store/oracle/weblogic:12.2.1.3-dev-200109
The weblogic console comes alive at https://localhost:9002/console/ but when trying to run the debugger, my IDE says:
Unable to open debugger port (localhost:4002): java.io.IOException
"handshake failed - connection prematurally closed"
My OS is Windows10. I tried with Visual Studio Code and IntelliJ, and got the same output. The WARs run just fine and they respond when I use portman to hit some service endpoints.
What seems to happen is that weblogic start scripts inside the container tries to apply the Java Options param twice! Please see the relative parts of container output below:
Domain Home is: /u01/oracle/user_projects/domains/docker_domain
Picked up JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,address=localhost:4002,server=y,suspend=n"
Listening for transport dt_socket at address: 4002
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
[...](and further down in the logs I get: )
Starting WLS with line:
/usr/java/jdk-8/bin/java -server -Djava.security.egd=file:/dev/./urandom -cp /u01/oracle/wlserver/server/lib/weblogic-launcher.jar -Dlaunch.use.env.classpath=true -Dweblogic.Name=AdminServer -Djava.security.policy=/u01/oracle/wlserver/server/lib/weblogic.policy -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader -javaagent:/u01/oracle/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/u01/oracle/wlserver/server -Dweblogic.home=/u01/oracle/wlserver/server weblogic.Server
Picked up JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,address=localhost:4002,server=y,suspend=n"
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
Stopping Derby server...
Derby server stopped.
I then tried to work with docker-compose, creating a .yaml file to add my environmental props there, trying to prevent these from running twice. I got the exact same behavior. Whichever port I use, it is found Already in use.
This is my .yaml file
version: '2'
services:
weblogic:
container_name: weblogic_yamled
image: store/oracle/weblogic:12.2.1.3-dev-200109
ports:
- "7001:7001"
- "7002:7002"
- "4002:4002"
- "4003:4003"
- "9002:9002"
volumes:
- c:/my-path-to-shared-volume:/u01/oracle/properties
environment:
- ADMINISTRATION_PORT_ENABLED=true
- DOMAIN_NAME=docker_domain
- JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:4002"
Finally, I tried transport=dt_shmem but then I got a different error:
ERROR: transport library not found: dt_shmem
Do not know what else I should try!
Try adding address=*:4002 instead of address=4002
JAVA_OPTS is a Tomcat specific environment variable
In Java 8 the JDK supports a JAVA_TOOL_OPTIONS environment variable so to enable the debugger. Try replace JAVA_OPTS with JAVA_TOOL_OPTIONS
You also have to setup the address like this: address=*:8000, address=localhost:4002 or address=0.0.0.0:4002
I had a similar issue with attaching a memory monitoring tool (JVisualVM).
I could telnet to the server but that was not the whole story.
From what I have understood what was blocking me was the RMI connection used under the hoods. What was missing was a "tunnel" between client (where your debugger runs) and host (where your application runs) machine.
In windows you would open a cmd and give:
putty.exe -ssh <username>#<remote-host> -L <port>:<remote-host>:<same_port_again>
This will open a putty window which should remain open after logging in for the tunnel to remain open.
For more information on this, you can check here on the 2nd step of the solution provided by #freedev.
I am not sure if it works for you but I suspect it may be the same case as mine.
The problem is that the WebLogic server in the container is configured to run in production mode (the value of the PRODUCTION_MODE variable in the script setDomainEnv.sh is set to "true").
To disable this You need open the file setDomainEnv.sh, find PRODUCTION_MODE="true" and change it to PRODUCTION_MODE="false".
You also don't need to set JAVA_TOOL_OPTIONS variable, setDomainEnv.sh script already has the possibility to start in debug mode.
To enable the debug mode, the environment variable “debugFlag” needs to be set to true before executing the script.
Docker command:
docker run -d --name weblogic -p 7001:7001 -p 9002:9002 -p 55195:55195
-v c:/my-path:/u01/oracle/properties
-e ADMINISTRATION_PORT_ENABLED=true -e DOMAIN_NAME=base_domain
-e debugFlag=true -e DEBUG_PORT=55195
store/oracle/weblogic:12.2.1.3
Note, I also change the debug port to 55195.
Have you tried using the port number + 3 (4005) instead? That's a common practice to have a separate debug port for containerized applications
I have a JBoss plugin running in IntelliJ. It runs fine, however when I try start it in DEBUG mode, I get the following error:
Application Server was not connected before run configuration stop,
reason: Unable to ping server at localhost:8080
I run my application on:
https://localhost:8443/
So I think I need to change the Detected server https port to 8443. Or do I need to connect the debug somehow?
Logs:
Detected server admin port: 9999
Detected server http port: 8080
/Users/richardmarais/Development/ClubTravel/jboss-as-7.0.2.Final/bin/standalone.sh
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /Users/richardmarais/Development/ClubTravel/jboss-as-7.0.2.Final
JAVA: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java
JAVA_OPTS:
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:50204,suspend=y,server=n
-javaagent:/Users/richardmarais/Library/Caches/JetBrains/IntelliJIdea2020.1/captureAgent/debugger-agent.jar
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
=========================================================================
Error occurred during initialization of VM agent library failed to init: jdwp /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java
-Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper /private/var/folders/47/11vw2x9x65z6pyvfrl3d9w1c0000gn/T/idea_classpath1206838148 com.intellij.javaee.oss.process.JavaeeProcess 56071 com.intellij.javaee.oss.jboss.agent.JBoss7Agent Disconnected from server Picked up JAVA_TOOL_OPTIONS: -Dhttps.protocols=TLSv1.2
-Xmx4096m -Xms128m objc[77083]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java (0x10b0144c0) and /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10b0fb4e0). One of the two will be used. Which one is undefined. ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options. Picked up JAVA_TOOL_OPTIONS:
-Dhttps.protocols=TLSv1.2 -Xmx4096m -Xms128m [2020-04-15 08:32:44,998] Artifact corporateInterface:war exploded: Waiting for server connection to start artifact deployment... Detected server admin port: 9999 Detected server http port: 8080
It looks like you append JAVA_OPTS somewhere in the environment or the server startup scripts so that the debugger is initialized twice which fails. Only options supplied by IntelliJ IDEA should be used, this one should not be in the options:
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
Notice that in Run/Debug configuration IntelliJ IDEA is supplying this instead:
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:50204,suspend=y,server=n
Inspect the .sh startup scripts for your JBoss, they are likely customized to add the old debug options which is causing the issue. Also it's a bad idea to use global environment variables like _JAVA_OPTIONS and JAVA_TOOL_OPTIONS, I would unset them.
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.
Getting below error when I try to do the remote debug in Spring Tool Suite IDE.
"Failed to connect to remote VM. Connection timed out.
org.eclipse.jdi.TimeoutException"
I followed the below steps to enable the remote debugging
deployed the war file in Tomcat server 8.
set up the env variable "JAVA_OPTIONS" value (-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8080,server=y,suspend=n)
start server by the command "CATALINA jpda start"
once server started
In IDE, Run --> Debug Configurations --> Remote Java Application,
create new application with the same project and host is localhost and port is 8080.
Note:
I improved my STS.ini memory to -Xms768m, -Xmx768m but unsuccessful.
not sure why my remote debugging is not working.
I guess Tomcat itself is running on port 8080, therefore I would recommend to use a different port for the debugging setup (-Xrunjdwp:transport=dt_socket,address=4000, for example). Then connect your remote debugging session in STS/Eclipse to that port.