I'm working with a certain external server product which happens to be proprietary. However, I do have the ability to modify the server's startup scripts. What I'd like to do is essentially set debugging breakpoints in the custom module code which I'm writing so as to be able to fix a bug I'm experiencing in my code.
Is there a way to do this, integrating Eclipse with debugging an external process?
If that certain external server product is a Java server, you should be able to debug your code running in it through standard Java remote debugging.
In Eclipse, open the Debug configurations and add a new configuraion of type "Remote Java Application", and enter the hostname of the server and the port the remote debugger listens to.
In the server startup script, you may need to add an additional Java option to enable remote debugging for the JVM and specify the port. Something like this (excerpt from the JBoss startup config file):
# Sample JPDA settings for remote socket debugging
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
(address - 8787 in this case - is the port to connect to)
Related
I am attempting to debug a remote Java application in a Linux environment with an argument. However, I can only find the option to define an argument when debugging a [local] Java application. The argument I am trying to define is java -Dsun.awt.disablegrab=true to avoid having the system hang when I debug in event handlers. Given the nature of this application, I cannot launch it locally; I can only debug it as a remote Java application and define the host as localhost. Is there a way to launch debug for a remote Java application with the aforementioned argument?
Thanks to everyone in advance!
In order to allow opening the port for remote debugging, the application (or its server)'s launch will be parametrized with Java command-line arguments already, e.g. something in the lines of:
-Djava.compiler=NONE -Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=[your desired port]
I would simply add your desired parameter to the list, when you launch the process in debug mode.
Where to find the launch configuration will depend on the type of application you're running.
Since you likely already know the port to connect to, you may want to grep it in your configuration files, in the targeted machine (i.e. in your local machine, in this specific case) - that might give you an idea what resource you need to make changes to.
Clarification
The idea here is that your local Eclipse is not launching the application when remote-debugging, it only connects to a socket of your own definition, with an open port to connect to your target machine.
Therefore, it it up to your application's launch configuration (i.e. how the java process is parametrized when launching your application) to define the socket for remote debugging if so required, and any launch parameters you may want.
I am attempting to configure an application for remote debugging. I am attempting to use the instructions under https://wrapper.tanukisoftware.com/doc/english/qna-eclipse-remote.html and have added the following lines to my wrapper.conf
wrapper.java.additional.16=-Xdebug
wrapper.java.additional.17=-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y
When I start my application using console console the application does not freeze with the following:
Listening for transport dt_socket at address: 8001
instead it carries on running and I cannot connect to it. Can anyone advise what settings I may be missing in order to allow the application to be remotely debugged.
One of the earlier configuration number was commented out
#wrapper.java.additional.13
This appears to mean that 14,15,16,17 were also ignored. I re-numbered these and can now debug.
Is it possible to setup JBoss server on one machine (PC) and then connect to it from another machine (laptop) ? I want to be able to run/deploy my application on the server on the PC and through Intellij on the laptop debug my code using that JBoss instance on the PC. I'm running a domain version of JBoss. Right now I have both the server and client running on the same machine. I'm not sure how to get around doing it, thanks for any help.
Yes it is possible to remote debug your application.
If you look at the first lines in the startup script standalone.[sh|bat], you'll see that debug agent can be enabled with the --debug command switch.
Switching this debug option will enable the JPDA and will listen on port 8787 by default.
This can also be achieved using JAVA_OPTS (look at the end of standalone.conf[.bat])
Once you started WildFly, you'll need to add a remote debug configuration in IntelliJ using the IP and port of your server. Here is the official documentation.
For remote deployment, you should have a look at the jboss-cli.
In Eclipse you can connect as follows, I'm sure Intellij must have something similar as well:
Run-> Debug Configuration->Remote Java Application. Here you can define the Host and Port of the application server, irrespective of it's location, be it local or any remote location.
I want to debug a java EE web application that run on Apache Tomcat. Is there any way to debug the application without stoping the server.
You can use remote debugging, but you'll need your server (once) to be started with the correct arguments for that. For instance, since you are using Tomcat, you can add these arguments in catalina.sh:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Then you can attach your debugger to REMOTE_IP:8000 and start debugging.
Always take into account that you are working in a production environment, so be careful with this.
The trick here is to start Tomcat with remote debugging enabled.
The easy way to do this is to use the options jpda start if you start tomcat using the catalina.sh or catalina.bat shell script.
If you are starting Tomcat using your IDE or something, then you must add the following options to the JVM that runs Tomcat:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
After you do that, then you need to configure your IDE to connect to the remote debugging port.
Check this Tomcat FAQ for more information.
you can't. The server have to be started in debug mode.
I invite you to read the wiki: http://wiki.apache.org/tomcat/FAQ/Developing
If you don't want to restart your live tomcat.
Create a new server (configured in debug mode), then copy you application on it.
Debug on this server.
I have the following configuration in the eclipse
Created a tomcat 7.0 server instance from the servers view.
Created a sample web application and deployed in the server through maven-tomcat-plugin and tested it in the browser ( started the server by right
clicking the server from the server view and selected start )
Tried to configure the remote debugging settings in the created server instance using JPDA options,i added the env variables in the server setting.
i could not connect the debugger to the server when i start the server from the eclipse as like previously.
But it connected seamlessly when i start the directly from the installation directory using the command prompt as like
catlina.bat jpda start
After that i tried this I started the server instance by ( started the server by right clicking the server from the server view and selected DEBUG mode)
I got the Break points in the code and even Hot Code replacement
working!!!
Can anyone explain the following?
What goes wrong when i tried jpda options for the remote debugging with the created server instance in the eclipse?
How the debug option and Hot Code replacement works with the server instance?Is this remote debugging or something else?Can you explain on this one?
the eclipse tomcat plugin spawns a separate JVM while running, you can confirm that in the windows task list, using ps in unix like systems or using visualVM.
That VM is launched in debug mode with the JPDA parameters set by the plugin itself, and that is how the debugging mechanism works, it's based on the JVM functionality. You can confirm which jpda parameters are used by using visual VM, that comes with the JDK.
I don't think you can override the JPDA parameters that the eclipse plugin setted for you, that's why in point 1) it did not work. For 2) it works via remote debugging made transparent by automatic setting the parameters and connecting the remote debugger once the server starts.