Remote debugging - Java - java

I am currently with a batch process that breaks into production, which is in a weblogic. This process can only be executed on a machine that is configured to run automatically.
My question is if a remote debugging can be done from my machine?

I really would not recommend remotely debugging a machine which is on production. However, if you must, you will need to do three things:
Startup the application with remote debugging turned ON on a port 80 or any other port of your choice by adding the following line to your java -jar command.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=80
For example,
sudo java agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=80 -jar original-example-service-local.war
This port needs to be accessible from your machine, you will need to open this port from your security group in AWS or however you are managing this instance. This step is very important.
Add the configuration in your IDE to do remotely connect to the application. You can find many guides on this online.
For IntelliJ --> https://docs.alfresco.com/5.2/tasks/sdk-debug-intellij.html
For Eclipse --> https://docs.alfresco.com/5.2/tasks/sdk-debug-eclipse.html
Hope this helps.

Related

How to enable hot code swap while debugging in eclipse and jboss when both code and the ear being deployed are on different remote machines?

The web application i am working on is very large and modularized, currently the ear is present as it is and not in exploded form on remote machine while the cod being debugged is on a different remote machine and i am unable to do a hot code replace as the architecture is complex and cannot be installed on the same machine.
Any suggestions to enable this would be really helpful...
we are using Jboss 7.x and java 1.8 and eclipse.
I do this type of debugging regularly in Wildfly/Jboss by setting the following in domain.xml
<server-groups>
<server-group name="s1" profile="s1">
<jvm name="default">
<heap size="3g" max-size="3g"/>
<jvm-options>
<option value="-agentlib:jdwp=transport=dt_socket,address=remote_server_name_or_ip:8000,server=y,suspend=n"/>
...
The key here is remote_server_name_or_ip:8000
Note how you need to specify the remote_server_name_or_ip before the port number.
Without this Wildfly/Jboss will listen on localhost only. You can also specify 0.0.0.0 so that the debugging process listens on all available IP addresses.
In Eclipse you simply need to specify the remote server IP address and port.
Hot swapping is automatic as long as you don't change method signatures, etc.
This logic is not limited to JBoss or Wildfly. You can use this approach to connect to any Java code running on another machine.
For example, please see my answer which explains how to allow remote debugging with Tomcat:
Remote debugging Tomcat with Eclipse

Debug code on one machine, run JBoss on another

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.

How do I build, deploy and debug standalone java app on remote machine?

How do I build, deploy and debug standalone java app on remote machine with IDEA ?
I have remote machine with certain hardware device connected to it. I want to develop standalone Java app on my PC, build it locally but the app should be deployed and running on remote machine accessible via SSH. Thus I'll be using Java remote debug.
I've googled extensively but couldn't understand if it's possible to achieve in IDEA (even though IDEA allows to do so for java servlet containers). I tried "Remote SSH External Tools" plugin. I'm not sure what to specify in following dialog (which seems to have bug)
What options do I have ?
If the machine is only reachable via SSH you need to do two things:
Configure your java application for remote debugging
Connect to the application via SSH
This tutorial should get you going: Remote Debug of a Java App Using SSH Tunneling

tomcat server instance debugging in the eclipse

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.

NativeProcess API Java Debugging?

What is your way to debug Java side when nativeProcess.standardInput.write method is invoked by Flex side? I know that it is possible but don't know how?
To be able to attach your Eclipse debugger to a running Java process you need to start that process with the following Java options…
-Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n
Once you have done this and have restarted the server, you can use your Eclipse to attach to the running process. From Eclipse go to the Debug manager and create a new Remote Java Application configuration for the process you want to connect to. Set the port number to 8001, the same as that of the options. You will also need to enter the hostname for the machine running the Java process. That is pretty much it…

Categories

Resources