Cannot connect to the remote server via Intellij for debug - java

I have a remote Linux server and an application on it which I need to debug. I start the .jar file through the terminal in Intellij with line:
sudo java -Dspring.profiles.active=test -Dspring.config.additional-location=file:/.../external.properties -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar /.../JARFILE.jar
Jar file is started correctly, the application is working, but I cannot debug it remotely via IDEA with those settings: remote debugging configuration.
It throws an error saying "java.net.ConnectException: Connection timed out: connect." after a few seconds from I clicked the debug button.
What should I do?

You say that you are unable to connect to the JVM via a debugger.
I'd expect that the reason for this error is the fact that you are not launching the JVM with the correct input arguments so that it can run in debug mode.
The easiest fix for this issue would be to allow IntelliJ to run it for you with correct configuration.
You say that you want to deploy the app to a remote server and debug it from there. Why not use this functionality in IntelliJ, which will guarantee that correct flags are set.
I think this value address=*:5005 might be wrong, try running it with address=5005

Related

How do I debug a Java app running in a Docker container in IntelliJ IDEA 2018.2?

I have a Java app that I'm attempting to debug inside of (because a particular error only happens when the app is run from inside Docker, which is fun), but I can't figure out how to get IntelliJ to attach for debugging.
I have the Docker Integration plugin installed, but when I go to run my container, the deploy log has a line that says Cannot retrieve debug connection: Debug port not specified. Google told me that I needed to add a debugPort entry to my workspace.xml file, but when I did that, my Run/Debug configuration complained that "Debug port forwarding not found". Clicking "Fix" resulted in a container_settings.json file being created, which IntelliJ immediately informed me wasn't supported in 2017.3+, and that i should use command line options instead. However, I have no idea what those command line options should be.
When I tried specifying the forwarding port in the Run/Debug configuration, the deploy log ended with Cannot retrieve debug connection: java.net.MalformedURLException: unknown protocol: unix, which makes no freaking sense.
Help!
You can even use dcevm / HotswapAgent in dockerized application and modify code/resorces without restart. Look at this project https://github.com/HotswapProjects/hotswap-docklands

Cannot debug Java application with Eclipse

I have a Java (Vert.x) application on my machine that I am trying to attach Eclipse to for debugging.
I usually start the Java application in my console like so:
java -jar build/libs/my-app.jar
Upon reading about debugging, I am attempting to start the app as follows:
java -jar build/libs/my-app.jar -Xdebug -Xrunjdwp:transort:transport=dt_socket,address=8001,server=y,suspend=n
The app seems to start up in the console fine when I run this.
I then go into Eclipse, and try to connect to the app via debugging via Run -> Debug Configurations. This is what my debug configuration looks like:
When I click debug, I get an error box that pops up and says that the connection is refused (I covered the name of my real app). See below:
What am I doing wrong? How can I get remote debugging to connect to my app with Eclipse?
According to my reading of this JDWP documentation, your -Xrunjdwp option is incorrect:
-Xrunjdwp:transort:transport=dt_socket,address=8001,server=y,suspend=n
should be
-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n
If your system has multiple IP addresses, there could be some confusion about which IPs the agent is listening for connections on. You could force a specific address; e.g.
-Xrunjdwp:transport=dt_socket,address=127.0.0.1:8001,server=y,suspend=n
and use the matching IP and port in the Eclipse debug connection parameters.
AND ... as Dave Thompson spotted ... all JVM options must be placed before the -jar argument. (Anything after the -jar name.jar will be treated as command line arguments for your application.)

Unable to run WebLogic Server in debug mode in Eclipse

I am not trying to do any remote debugging in Eclipse. I am just trying to run WebLogic Server (which is in Eclipse) in DEBUG mode. I am getting a strange error message, which is shown in the attached image. The server is not starting from Eclipse when I try after this option. I am using Java 1.6
Do below setting to start debugger, it works fine in my case:
Edit /bin/setDomainEnv.sh file and add this on top:
JAVA_OPTIONS="$JAVA_OPTIONS -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
The suspend=y will start your server and wait for you to connect with IDE before continue.
If you don't want this, then set to suspend=n instead.
Start/restart your WLS with /bin/startWebLogic.sh
Once WLS is running, you may connect to it using Eclipse IDE.
Go to Menu: Run > Debug Configuration ... > Remote Java Application and create a new entry.
Ensure your port number is matching to what you used above.

How to enable remote debugging for an Eclipse Application?

Im trying to enable remote debugging for an eclipse plugin project, for the purpose of using IntelliJ IDEA as a debugger.
The steps I've taken so far:
Launch Eclipse.
Run -> Debug Configurations...
Create a new "Eclipse Application" (as to launch a local workspace which loads the plugin).
Add -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n to VM arguments.
Press the Debug button.
I get the following error:
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
Error occurred during initialization of VM
agent library failed to init: jdwp
What steps should I be taking to get IntelliJ IDEA to be able to debug an Eclipse Plugin running in a runtime workspace?
Run -> Debug Configurations...
Add -Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend=n to VM arguments.
This is redundant. Using a debug configuration already starts the application with the eclipse debugger attached to the process. Start it as a run configuration instead if you want to enable debugging through a server socket.
You can then create an additional "remote java application" debug configuration to attach to that socket.
I would suggest you NOT try to launch the Eclipse app from within Eclipse.
Export the app to be a stand alone eclipse application.
Modify the eclipse.ini file and add the necessary debug parameters to the '-vmargs' entry.
Launch the stand alone app as you normally would.
Attach the development Eclipse instance to the test app as you would normally do for a remote debug.
Tomcat Configuration:->
By default remote debug happens at 8000 port.If you want to change this then go to catalina.bat file and update this line
set JPDA_ADDRESS=localhost:8000 to desired port no.
And you can also set this property in setenv.bat file. Generally this file is not there in tomcat so just create one batch file with name
setenv and write this line set JPDA_ADDRESS=localhost:8000.
Now go to bin directory then open command promt and write "catalina jpda start". It will make the tomcat run in debug mode. You can verify it
by seeing something like this "Listening for transport dt_socket at address: 8000"
1)Eclipse
Go to run->debug configuration->Remote Java Application->Click on new Launch configuration
And then fill the detials like project ,port(Give same port no as you have configured in tomcat), host(If you are using local you can give
local then apply and debug
I am using eclipse 2020.09 .
Eclipse remote debug img
2)Intellij Idea:
Go to Add configuration->click on +->and select remote jvm debug->Then give the same port no and name(any name) then apply.
Intellij Idea Remote Debug img

Eclipse WebLogic debugging

I know you can debug by just clicking the debug icon in Eclipse. Is it possible to start WebLogic from the command line with debugging and still debug? When I do that, in Eclipse under server I see that the status is "Started", not "Debugging". Can this only be done by setting up remote debugging?
You need to add parameters to the JAVA_OPTIONS in the startWebLogic.cmd (or startWebLogic.sh):
-Xrunjdwp:transport=dt_socket,server=y,address=1044,suspend=n -Xdebug
Then, in Eclipse you have to use remote debugging indeed.
Add a new Remote Java Application in the Debug Configurations (via the menu: Run - Debug Configurations).
Make sure the correct project is selected (Browse button) and fill in localhost in Host and 1044 in Port. The other options you can leave unchanged.
If you click debug you should be able to see your remote WebLogic running in the Debug perspective.
If you see a WebLogic started under Servers, you are looking at an embedded server and not at the one you started via the command line. Make sure to stop any embedded server before starting via the command line as they will not be able to run on the same port together anyway.

Categories

Resources