How to enable remote debugging in JBOSS 5? - debugging

How do you enable remote debugging in JBoss 5? The usual line from JBoss 4:
set JAVA_OPTS= -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
As can be found in other answers like this do not seem to work. The server never suspends. Googling "jboss 5 remote debug" doesn't bring up anything in the JBoss docs. Did something change from JBoss 4? How can I remotely debug my JBoss 5 server from eclipse?

You have suspend=n in your options. Change this to suspend=y.
Or is the line you posted not the one you're using with JBoss?

We have to do 2 changes to debug remote java application that is running in JBoss
Configure in JBoss
Creating remote debugger in in eclipse
Open run.conf.bat(windows) or run.conf(Linux) file in JBoss bin folder.
go to the below lines
`# Sample JPDA settings for remote socket debugging`
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
and remove hash in JAVA_OPTS
# Sample JPDA settings for remote socket debugging
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
Restart the server if it is started.
2. In Eclipse, Run -> Debug configuration -> Remote Java Application and create a new.
Note that you have to give port that is mentioned in run.conf.bat file

Related

Debug J2EE Applications on IntelliJ Community Edition and Tomcat8 (running as a service)

I've searched a lot on Remote Debugging a REST APIs written in Java using IntelliJ IDEA Community Edition.
My Setup:
Windows 10
Tomcat installed as a windows service
Java 8
Intellij Community IDE
Finally after some googling and sifting through SO, found a solution that works. Posting it below.
Part I. Running Tomcat in Debug Mode
When running Tomcat8 as a service
Open {$TOMCAT_HOME}\bin\Tomcat8w.exe
Under Java > Java Options add the following lines to enable the debug port 8001:
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001
Restart the Tomcat Service
Part II. Attaching IntelliJ IDEA Remote Debugger
Create a new Run Configuration using the Remote Template.
Under Configuration > Settings Change the Port to 8001
Run the new config by clicking on the debug icon and IDEA will connect to the debug port of Tomcat
Credits:
How to remotely debug the webapplication running on tomcat service?

How can I run wildfly in debug mode, as a service on Windows?

I am running Wildfly as a service on windows. When I need to debug, I am shutting this down and starting Wildfly via standalone.bat -debug. What I want is to have the debug switch on always, when it runs as a service?
Uncomment following JAVA_OPTIONS from $JBOSS_HOME/bin/standalone.conf.bat
rem # Sample JPDA settings for remote socket debugging
set "JAVA_OPTS=%JAVA_OPTS%
-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
start service. Now you can detach a debugger with your favorite IDE. If you are using Eclipse you can switch to "Debug-Configurations" and add a new Remote Java-Application.
I'm using WildFly 11 and uncommenting the following lines in bin\standalone.conf.bat (windows) did the job:
set "DEBUG_MODE=true"
set "DEBUG_PORT=8787"
Open the command line and set java options with the following debug options:
set JAVA_OPTS = -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,suspend=n,server=y
start wildlfy service by running standalone.bat or standalone.sh for windows/linux respectively

intellij idea 14 cannot connect to debug tomcat7 service

Ok, I think I tried everything before I am posting this question. Please tell me, what I am (Still) missing. I keep getting "unable to connect" exception (unable to connect hostname:6012), I changed from default port 1099 and it still didn't help.
version of IntelliJ 14.0.2
Tomcat 7.0.52
Tomcat is running as a service so, I configured on the UI interface of tomcat.exe (java tab) the following JAVA_OPTs
-Xdebug
-Xrunjdwp:transport=dt_socket,address=57497,server=y,suspend=n
-javaagent:C:\Users\username\.IntelliJIdea14\system\groovyHotSwap\gragent.jar
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=6012
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcatalina.home=C:\Tomcat 7.0
-Dcatalina.base=C:\Tomcat 7.0
-XX:MaxPermSize=512m
I made sure the port 57497 is open (open the firewall and telnet).
And on IntelliJ, I made a remote server connection. Please find attached
pictures. Both intellij and tomcat are running on the same system. I have a static dns setup. sometimes i get connection timedout exception.
server tab
connection tab
Here's my config.
Tomcat JAVA_OPTs to enable remote debugging:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5007
In IntelliJ, I don't use the Configuration-Type 'Tomcat'. In my case 'Remote' works pretty well (I would post an image but I ain't got 10 reputation...). You only need to configure your host and port on the config sheet.
I use IntelliJ 14.0.3 and I had the same issue, though with Jetty. Switching to using the remote instead of jetty -> remote worked. I'm guessing they're both supposed to work differently. I just haven't figured out why there are two different options to remote debug.

tomcat debugging

I am working on a project where the backend code is in Java.
I want to debug this code and am running tomcat in the debug mode correctly .
I have the Java code in Eclipse where I set up a new debug config for Remote Java Application and start the debugging.It shows no error but it is not breaking at the breakpoint.
So the Tomcat Webapps folder has only a copy of the Servlet classes and my Java code is in a folder at some other place.
Is this the reason that I am not being able to link them properly
You have to start tomcat with the JPDA options in order to debug remotely. Under *nix, issue "catalina jpda start" instead of "catalina start".
If you want to do a remote debug to figure out a problem in code, then your code locally must be the same. Also remember to connect to the correct port, 8000, I believe.

Can't setup remote debugging with JBoss Web 2.1.4 windows and eclipse

I'm unable to find an option to setup remote debugging in JBossWeb 2.1.4 on Windows. It is not installed as a service and there are no .bat scripts where I can edit the JAVA_OPTS environment variable to include:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4142
The only thing in the jboss web bin directory are jbossweb.exe files.
I've tried editing the run configuration in eclipse to start the container by running jbossweb.exe and setting the environment variable JAVA_OPTS to the above, but it doesn't listen on port 4142 on startup (ie, there seems to be no effect in adding the environment variable to the run configuration).
Any ideas here?
If you control the server from eclipse with for instance JBoss Tools, you can just click "debug" instead of "start" in the Server pane in order to start up in debug mode.
You can create such bat script by yourself. Just add jboss.bat file to bin subdirectory of JBoss install directory and put there:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4142 -jar "D:\JBoss.org\JBoss Web 2.1\bin\bootstrap.jar" start
When you run this script, you will get JBoss running in debug mode. Probably, it won't help you in all situations, but it worked for me.

Resources