According to home page of gradle tomcat plugin FAQ section:
How do I remote debug my Tomcat started up by the plugin?
I need to add the following environment property:
GRADLE_OPTS = -Xdebug Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
During run of container I should see information that it listens on particular port: Listening for transport dt_socket at address: 5005, but in my case it's not working.
How I can configure it properly ? I'm running intellij idea 14.1 Ultimate.
In my case it worked as I started the Tomcat in the IDE itself and not the CLI.
For that I created two run/debug configurations, one for Tomcat and one to Remote connect the debugger to the Tomcat process.
For the Remote configuration, use the port 5005 like mentioned in the plugin FAQ debug section.
For the Tomcat configuration, you have to set the JVM settings explicitly. Simply put -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 as a value into the JVM options textfield in the Gradle run/debug config.
After both configurations have been created and properly configured, first run the Tomcat process and then connect to it by debugging the Remote configuration.
You can find an entire spring-mvc example and an detailed solution here.
I am attempting to Debug a simple Java Server Application hosted on localhost on any given port. Within Eclipse I run it in debug mode to wait on an incoming connection. When I run my a browser to retrieve data from the server I get nothing. If I run the Application outside of Eclipse, everything is fine and my pages are served.
Is there anything I need to do in Eclipse to enable ports or anything?
I saw this post:
How does Eclipse debug code in an application server?
but that is only informational. Any help would be great.
To debug applications that run on another JVM or even on another machine, start them with these flags:
java -Xdebug -Xnoagent \
-Djava.compiler=NONE \
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
Enter the hostname and port to connect for debugging:
Run → Debug Configuration... menu
Create a new debug configuration of the Remote Java Application type.
This configuration allows you to enter the hostname and port for the connection.
Eclipse Settings:
1.Click the Run Button
2.Select the Debug Configurations
3.Select the “Remote Java Application”
4.New Configuration
a) Name : GatewayPortalProject
b) Project : GatewayPortal-portlet
c) Connection Type: Socket Attach
d) Connection Properties:
i) localhost ii) 8787
For JBoss:
1.Change the /path/toJboss/jboss-eap-6.1/bin/standalone.conf in your vm as follows:
Uncomment the following line by removing the #:
JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
For Tomcat :
In catalina.bat file :
Step 1:
CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
Step 2:
JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Step 3: Run Tomcat from command prompt like below:
catalina.sh jpda start
Then you need to set breakpoints in the Java classes you desire to debug.
Hope this helps.
I want to set up breakpoints and remote debugging for a Jboss application in Intellij. From this blog post, I believe the first step is to run jboss in debug mode. I have Jboss 5.1.0.GA. so I don't have the same files (standalone.sh) as mentioned in How to start JBOSS 7 in debug mode?">this Stack Overflow which covers it for Jboss 7.
How do I do this for Jboss-5.1.0.GA? In run.conf, I see these two lines:
# Sample JPDA settings for remote socket debugging
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
# Sample JPDA settings for shared memory debugging
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_shmem,address=jboss,server=y,suspend=n"
Is all I need to do uncomment one of those? Then in Intellij what would be the corresponding settings? Here:
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=n
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
I know this is an old post but just answering it speciffic to intelliJ IDE
Step 1
In the JBOSS start-up we add the below line
JPDA options. Uncomment and modify as appropriate to enable remote debugging.
set JAVA_OPTS=-classic -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n %JAVA_OPTS%
Step 2
Run JBoss with the above script
Step 3
In intelliJ under run/debug configuration add jboss like the screen grab below
Step 4
Start the JBoss config in debug mode by clicking on the debug icon.
How can I configure remote debugging in Eclipse with JBOSS server 4.x version?
So far,
Step1: I have modified the run.confg file. By uncommenting the below line. Sample JPDA settings for remote socket debugging:
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
Step2 : Then I configured Eclipse in debug configurations. It's saying:
Failed to connect to remote VM. Connection refused.
What you are asking is not specific to either Java EE or JBoss 4.x - you can debug any Java process in case you specified the remote debugging runtime parameters when starting the JVM.
In your setting the -Xdebug parameter is missing, so your line would be:
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
Now it should be able to connect, in case you are using the correct host and your specified port 8787. In case it's still not working, it's most likely a firewall issue blocking the port.
I know there's some JAVA_OPTS to set to remotely debug a Java program.
What are they and what do they mean ?
Before Java 5.0, use -Xdebug and -Xrunjdwp arguments. These options will still work in later versions, but it will run in interpreted mode instead of JIT, which will be slower.
From Java 5.0, it is better to use the -agentlib:jdwp single option:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044
Options on -Xrunjdwp or agentlib:jdwp arguments are :
transport=dt_socket : means the way used to connect to JVM (socket is a good choice, it can be used to debug a distant computer)
address=8000 : TCP/IP port exposed, to connect from the debugger,
suspend=y : if 'y', tell the JVM to wait until debugger is attached to begin execution, otherwise (if 'n'), starts execution right away.
I have this article bookmarked on setting this up for Java 5 and below.
Basically run it with:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
For Java 5 and above, run it with:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044
If you want Java to wait for you to connect before executing the application, replace suspend=n with suspend=y.
Since Java 9.0 JDWP supports only local connections by default.
http://www.oracle.com/technetwork/java/javase/9-notes-3745703.html#JDK-8041435
For remote debugging one should run program with *: in address:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000
For java 1.5 or greater:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 <YourAppName>
For java 1.4:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 <YourAppName>
For java 1.3:
java -Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 <YourAppName>
Here is output from a simple program:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 HelloWhirled
Listening for transport dt_socket at address: 1044
Hello whirled
java
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8001,suspend=y -jar target/cxf-boot-simple-0.0.1-SNAPSHOT.jar
address specifies the port at which it will allow to debug
Maven
**Debug Spring Boot app with Maven:
mvn spring-boot:run -Drun.jvmArguments=**"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001"
Command Line
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=PORT_NUMBER
Gradle
gradle bootrun --debug-jvm
Maven
mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=PORT_NUMBER
Here is the easiest solution.
There are a lot of environment special configurations needed if you are using Maven. So, if you start your program from maven, just run the mvnDebug command instead of mvn, it will take care of starting your app with remote debugging configurated. Now you can just attach a debugger on port 8000.
It'll take care of all the environment problems for you.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=PORT_NUMBER
Here we just use a Socket Attaching Connector, which is enabled by default when the dt_socket transport is configured and the VM is running in the server debugging mode.
For more details u can refer to : https://stackify.com/java-remote-debugging/
If you are using java 9 or higher, to remotely debug (which is also the case when you use docker at local) you have to provide --debug *:($port). Because from java 9 --debug ($port) will only allow to debug at local, not remotely.
So, you can provide command in docker-compose like
command: -- /opt/jboss/wildfly/bin/standalone.sh --debug *:8787