IntelliJ - Remote debug - Unable to open debugger port - java

I am using IntelliJ 2017.3 with Payara 4.1.2.172. I used to just start the server from the command line had a Remote Debug running on port 9009, and everything used to work fine.
Then I set up an plugged in server with attached modules in IntelliJ, to enable HotSwap. I run this server in debug mode, and it works fine.
Now, if I don't use the plugged in server, but want to start the server as previous, when I run the debug remote, I get the following:
Error
Error running 'Debug Glassfish OSM': Unable to open debugger port
(localhost:9009): java.net.ConnectException "Connection refused:
connect"
I have run a netstat and there's nothing running on port 9009.
Question
How do I get the remote debug working on the server?
More info
The domail.xml has:
<system-property name="JAVA_DEBUGGER_PORT" value="9009"></system-property>
And in the server-config JVM Settings:
More info
I set the above 'Enable' checkbox to on, but now I get the following error when I try start the server, i.e. the server won't start now. (netstat shows noting running on port 9009)
ERROR: transport error 202: connect failed: Connection refused 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]
If I set it to off in the damain.cml, I still get the error and am unable to start the server.
<java-config classpath-suffix="" debug-options="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${JAVA_DEBUGGER_PORT}" debug-enabled="true" system-classpath="">

In glassfish\domains\domain1\config\domain.xml :
<java-config classpath-suffix="" debug-options="-agentlib:jdwp=transport=dt_socket,address=9009,server=y,suspend=n" java-home="C:\Program Files\Java\jdk1.8.0_162" debug-enabled="true" system-classpath="">
or in http://localhost:4848/common/index.jsf
2. In current Idea - Server Run Configuration - Debug - Port - address

I had the same problem and this solution also did the trick for me: Provide the IP 127.0.0.1 in the Intellij Debug configuration instead of the host name "localhost", in case you're using this hostname.

I have simple solution on that but its not permanent fix on this issue. You can invalidate and restart your IntelliJ Idea and try again to debug your codebase.

Related

Unable to attach remote debugger to app in PCF

I have multiple applications running in PCF and can remote debug in to all but one of them. I use the same configuration making sure that
JBP_CONFIG_DEBUG: {enabled: true}
is properly set and picked up by the app.
I run cf ssh -N -T -L 8000:localhost:8000 in command line and verify in PCF Apps Manager that the ssh session is established.
When I run the debug session in Intellij I get the error in Intellij.
Unable to open debugger port (localhost:8000): java.net.SocketException "Connection reset"
And this error in CMD.
connect to localhost:8000 failed: ssh: rejected: connect failed (dial tcp 127.0.0.1:8000: getsockopt: connection refused)
I can ssh into the app with cf ssh with no issue.
I am not sure what the problem is or if there is something I am missing, but this same process work for the other applications.
Any help would be great.

Problems with heroku remote debugging in IntelliJ

I started the command "heroku ps:forward 9090 --app [app-name]". I added a "Remote" debug configuration in IntelliJ, and set host to "localhost" and port to "9090". I start the debugger, and after a while I get this message:
"Error running '[configuration name]': Unable to open debugger port (localhost:9090): java.io.IOException "handshake failed - connection prematurely closed".
I checked with netstat that port 9090 is actually listening for a connection.
So it turns out that in order to enable debugging with heroku, you need a "Procfile". It is possible to run an instance without this file, but then the default parameters are used (and that's obviously what we were doing).
After adding this "Procfile", debugging finally works:
web: java -Dserver.port=$PORT $JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,address=9090,suspend=n -jar target/<.jar file>

Remote Debug for Cloud Foundry application fails when connecting eclipse remote debugger to forwarded local port

I'm trying to remotely debug a Spring boot application deployed on a cloud foundry Instance. Below are the steps that I'm following to setup remote debug using eclipse:
Setting up JBP_CONFIG_DEBUG: '{enabled: true}' environment variable for the application.
After that I'm setting up the local port forwarding to my app container with cf ssh -N -T -L 8000:localhost:8000 <APP_NAME>
Then I'm setting up the remote debug configuration in eclipse as shown below image:Eclipse remote debug setup
After that when I try to start remote debug session, It tried to connect to the app but fails with the message at the port forwarded terminal:
connect to localhost:8000 failed: ssh: rejected: connect failed (dial
tcp 127.0.0.1:8000: getsockopt: connection refused)
Please help, if anyone has any clue about this error!!
You might have to restage the application for the change to take place, debug configuration to change.
You can use alternatively ssh into the container using cf ssh <application name> and check that the debug port is opened on not using netstat -an
We had some issues as well, but with a specific java buildback, but anyway mabe it'll help you in your case as well, try:
cf set-env <app-name> JBP_CONFIG_JAVA_OPTS '[java_opts: "-XX:+ForceDebuggingOnDemand"]'
cf restage <app-name>
try to change debugging port like this:
JBP_CONFIG_DEBUG "{enabled: true, port: 8001}"

Unable to debug in Java with eclipse

I am trying to debug a simple Java application on my machine using Eclipse as an IDE. When I try to debug the application by entering the Debug Perspective, I set a breakpoint and start debug. Within a few seconds, the following pop-up window:
Launching unicodeRead has encountered a problem. Cannot connect to VM.
The message dumped on the console is as follows:
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:708]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
How do I correct this? Why does this happen?
I just had the same problem.
Yesterday everything worked fine, now nothing - same error as you gave. I found out that network admins made some changes in the meantime. Some firewall stuff. Problem is that Eclipse tries to establish connection to JVM at "localhost" (and some random port). When I tried pinging localhost (or 127.0.0.1) I got following:
C:\Windows\system32>ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data:
PING: transmit failed. General failure.
PING: transmit failed. General failure.
PING: transmit failed. General failure.
PING: transmit failed. General failure.
and
C:\Windows\system32>ping localhost
Ping request could not find host localhost. Please check the name and try again.
It seams that in some cases DNS is expected to resolve this, and if firewall prevents localhost requests to DNS - stuff breaks. I had to alter hosts file and remove comments in following lines, so I would not rely on DNS for this anymore:
# 127.0.0.1 localhost
# ::1 localhost
Although it is written that hosts file changes take effect immediately, I think that some processes locked this and restart was necessary in my case. After that, everything worked again.
Had same problem, but the solution was to run the application with -server=y option and not with -server=n.
Before:
java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:5005
After:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005
Looks like the same problem as here. A reboot of the pc fixed the problem there. I haven't found any other solutions.
I was seeing an error while using the -X format:
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp
The error went away when I switched to the newer format:
java -agentlib:jdwp=transport=dt_socket,server=y,address=4000,suspend=n myapp
Its Very Simple,Just do the Following Changes in eclipse.ini file.
-vm
binary\com.sun.java.jdk.win32.x86_1.6.0.u43\jre\bin\javaw.exe
I changed
-agentlib:jdwp=transport=dt_socket,address=9009,server=n,suspend=y
to
-agentlib:jdwp=transport=dt_socket,address=9009,server=y,suspend=n
and that did the trick!
My case is I have a bunch of domains refer to 127.0.0.1 in hosts file, like this:
127.0.0.1 localhost domian1.local domain2.local domain3.local
one day I added another new domain to refer to 127.0.0.1. By mistake, I put the domain in front of "localhost", like this:
127.0.0.1 domain4.local localhost domian1.local domain2.local domainx.local
After this, I always got an alert window in eclipse while debugging:
Cannot connect to VM
com.sun.jdi.connect.TransportTimeoutException
In console:
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP: Failed to initialize transport via localhost:50470, trying localhost via 127.0.0.1:50470
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
The solution is keep "localhost" at the first position all the time.
127.0.0.1 localhost domian1.local domain2.local domainx.local domain4.local
What solved for me was deleting the entire domain1 folder inside the domains folder on glassfish main folder.
Eclipse will ask you to recreate a domain and then everything works again.
In eclipse select Run tab -> Debug configuration -> Junit -> select your test name ->
Environment tab -> add variable server=y .
I was getting the same error on my ubuntu machine because of a mishap with the /etc/hosts file. I had commented out the mapping of localhost to 127.0.0.1, and to complicate matters further there was a swap file hanging around.
This was the first line of my /etc/hosts:
127.0.0.1 #localhost
Deleting the # fixed the problem, whereas rebooting understandably had not.
My cause & solution were completely different.
I think in my case it was due to the installation of JProfiler. I fixed it by uninstalling JProfiler and launching eclipse with the -clean option. I suspect that JProfiler was inserting itself in the debugger. The -clean option forces Eclipse to re-assess its plugins, so that alone might have been sufficient.
Continuing #gonadarian's answer, it seems Eclipse uses port 127.0.0.1 for debug purposes. This port is also called localhost. The way this error can be removed is by ensuring that there are no processes or services running on the above ports. The way to do this, on Linux is:
As root, enter the command:
netstat -tulpn | grep 127.0.0.1
If there are processes running on the above port, it will show up in the format:
process_id/process name.
Kill the above processes like so: kill -KILL process_id
Restart the computer for these changes to take effect. The error should no longer occur.

remote debugging a jnlp application with IntelliJ

I'm trying to debug a web start application using IntelliJ 10 (running on Win7).
I read both SO:
remote debugging a jnlp application with eclipse
How can I debug applications under Java Web Start (JNLP) ?
It seems like I'm missing something.
I've tried to run it from command line, or adding the arguments into the jnlp file but no matter what I do I get an Unable to open debugger port : java.net.ConnectException "Connection refused: connect" Error.
How can I debug a web start app?
I know it's stupid, but once I changed the port from 5000 to 5005 it all works.

Categories

Resources