Remote debug jnlp with IntelliJ - java

I am trying to debug a jnlp with IntelliJ but it keeps telling me
Unable to open debugger port (localhost:5005): java.net.connectException "Connection refused: connect"
First I start the jnlp via command line with
javaws -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 http://server:port/app.jnlp
afterwards I run the remote debug configuration in IntelliJ and I get the aforementioned exception
Screenshot of the IntelliJ configuration and the command line:
I've already read following questions:
Debugging JNLP started application
How can I debug applications under Java Web Start (JNLP)?
remote debugging a jnlp application with IntelliJ
Remote debugging java web start under JVM 1.8
but their answers (add arguments via Java control panel, set JAVA_TOOL_OPTIONS variable, ...) don't seem to work for me.
Any idea what I might be doing wrong?
I'm using IntelliJ 2017.1.5 and JDK1.8.0_121 on Windows 7.

Related

Running Eclipse configuration from the console

I am trying to run the xtend Server (ServerLaucher.xtend) as a Java Application. It works if I execute it in eclipse. If I open the Run Configuration, click on Show Command Line, copy the code from it (which looks like this one)
/usr/lib/jvm/java-8-openjdk-amd64/bin/java
...
mydsl.web.ServerLauncher
and run it in a normal terminal, the server starts as normal and says that it is available under localhost:8080. The problem, however, is that, in contrast to running it in Eclipse, the website doesn't work and I got the error website:
HTTP ERROR 503
Problem accessing /. Reason:
Service Unavailable
Powered by Jetty://...

Remote Debug Tomcat 7 With IntelliJ

I have a web application running on 10.0.1.62:8080/xxx. I want to debug remotely via IntelliJ IDEA. I have set JAVA_OPTS = -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
on 10.0.1.62 machine(Tomcat7 on Ubuntu) and when I hit the remote debug button IDE is giving an info message :
Connected to the target VM, address: '10.0.1.62:8000', transport: 'socket'
Than I am hitting the 10.0.1.62:8080/xxx.
Although I get this success message brekpoints are not hit. What am I missing ?
Firstly, double check your settings by referencing this question and answer: Remote Debugging in IntelliJ Tomcat
From you question it sounds like you have already followed these steps. There are a few other config problems that have caused me issues with remote tomcat debugging in the past that I'll share and hope it helps.
Be sure you started the proper remote debugging process on IntelliJ.
Make sure you are connecting to the correct Tomcat instance, if there are multiple Tomcat servers running on your host. The debug port 8000 may already be in use. I'm use an arbitrary port of 15019 or some other port number not already in use. Make sure the ports used match between Tomcat and IntelliJ.
Depending on how you setup remote debugging on Tomcat, it may not shutdown properly leaving an old instance running. Adding the debug hooks at the top of catalina.sh will cause the shutdown.sh script to fail because your debug port is already bound to the Tomcat server. Instead place it within the start if statement:
elif [ "$1" = "start" ] ; then
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=15019,suspend=n,server=y"
After fixing this issue, you can shutdown Tomcat successfully with ./shutdown.sh and still start debugging with ./startup.sh
Make sure you have a clean deployment of your application on Tomcat. Your cleanup process may require variations, but here is the general idea:
Shutdown Tomcat, then verify it is no longer running.
Remove the deployed war file and corresponding exploded version from your tomcat webapps directory.
Remove the contents of the work and temp directories.
Deploy and verify your recently build war file.
Start Tomcat.
Creating a script to do this will save time.
If all else fails, add a debug log to double check the code with the breakpoint is being invoked in the first place.
I'm sure there are twenty other things that could go wrong. Feel free to add ideas.

How can I remote debug my rcp application?

Because my RCP eclipse application fails when run outside of eclipse, but works correctly when running inside of eclipse, I am attempting to use eclipse to remotely debug my application as it's running outside of the eclipse environment.
I am using 32 bit Eclipse 3.6.1 on a 64 bit Windows 7 machine. I am using 32 bit Java 1.6 update 37. I use the Eclipse Product export wizard to package the app, and I end up with an eclipse.exe. I have created a Remote Debug Configuration and set it to use port 8765 (random number). For debugging purposes, I start the app from the command line using this line:
eclipse.exe -Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8765
Depending on whether I am attaching or listening via my Eclipse debugger, I will add the server=[y/n] option to this command line but it seems not to make any difference.
For the configuration Connection Type I have tried both Standard (Socket Listen) and Standard (Socket Attach). When I try Socket Listen, my debugger will start listening - "Waiting for vm to connect at port 8765", but when I start my app through the command line, the app starts fine but the debugger never attaches.
When I try Socket Attach, I start the app first using the command line, then when I attempt to attach using eclipse, I get the message "Failed to connect to remote VM. Connection refused"
I've tried all the various combinations of address: localhost, 127.0.0.1, and my local IP address. I get the same result each time.
Thanks for any help!
You are missing the -vmargs parameter. Try "eclipse.exe -vmargs -Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8765"
I was searching for the same thing and found the answer in this helpful post http://blog.ankursharma.org/2010/05/remote-debugging-eclipse.html
this is better:
http://exploreeclipse.blogspot.com/2016/05/eclipse-rcp-remote-debugging.html
Defining the server and suspend arguments
$./TOS_BD-macosx-cocoa -vmargs -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8989
Another way of debugging your RCP application is to launch it with "-console" "-consolelog". This gives you the osgi console, where you can examine which bundles did (not) start, the services that are exported etc. Type help to get a list of commands available.

Java plugin does not attach to debug session in Eclipse

this functionality used to work and now it seems broken, I a do not know how to diagnose it.
I am developing a java Applet that runs in a browser. I used to set up the runtime parameters in the java console to (Windows platform):
-Djava.compiler=NONE -Xnoagent -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=n,suspend=n
This setting appears both in the User and System tabs in the Java console.
Then I would start a debug session in eclipse for my applet project and set it to listen on port 8000. When I launch the browser and the applet is loaded, it would attach to eclipse and I was able to debug and set breakpoints, etc.
Now, it seems that this is no longer happening. When I launch the debug session in Eclipse, I do see port in LISTENING mode and owned by javaw.exe, which is correct. The only problem is that when the browser loads the Java plugin, it does not honor the "Runtime Parameters" and does not connect to the listening debug session in eclipse.
I have the latest Java update installed.
What else should I be looking into?
I just resolved my issue.
I edited:
C:\users\\AppData\LocalLow\Sun\Java\Deployment\deployment.properties
and added the pararameters as follows:
deployment.javaws.jre.0.args=-Djava.compiler\=NONE -Xnoagent -Xdebug -Xrunjdwp\:transport\=dt_socket,address\=8000,server\=n,suspend\=n
When i added the runtime parameters through the UI, they went to
"deployment.javaws.jre.1.args" so I duplicated them into "deployment.javaws.jre.0.args"

How to debug a JSP tomcat service using eclipse?

I would like to debug my separately running JSP/Struts/Tomcat/Hibernate application stack using the Eclipse IDE debugger. How do I setup the java JVM and eclipse so that I can set breakpoints, monitor variable values, and see the code that is currently executing?
I just Googled it. :)
http://bugs.sakaiproject.org/confluence/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging
Many more on google.
Effectively, set your JPDA settings:
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
bin/catalina.bat jpda start
Then, in Eclipse, Run->Debug Configurations...->Remote Applications.
Follow these steps:
Add the following arguments to the java command that is used to launch Tomcat (on Windows, I think this is in TOMCAT\bin\catalina.bat)
-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
In Eclipse, create a 'Remote Java Application' debug configuration and set the port to 8787 and the host to the name (or IP address) of the machine where Tomcat is running. If Tomcat is running on the same machine as Eclipse, use 'localhost'.
In the 'source' tab of the debug configuration, add any projects that you want to debug into
Start Tomcat
Launch the debug configuration you created in step 2
Eclipse should now stop at any breakpoints that you've set in the projects you added in step 3.
Notes:
You can change the port to any other available port if for some reason you can't use 8787
If you want Tomcat to wait for the remote debugger to start, use 'suspend=n' in the command above to 'suspend=y'
You could do what they suggest, or use this Eclipse plugin, which makes it easier to configure Tomcat to begin with: Eclipse Tomcat Plugin
When launching tomcat via this plugin, it starts in debug mode by default, you must explicitly disable debugging mode if you want it to not allow Eclipse to connect a remote debugger.
For Tomcat 5.5 on Windows:
Edit bin/startup.bat
Find the line that reads:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
Replace it with these lines:
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

Categories