I am trying to debug a Java EE/Jakarta EE with NetBeans 12 and Gradle 7.5. I know how to call a task for debugging purposes from NetBeans.
I can create a task to call from NetBeans to debug a regular Java app. I am having trouble when I have to debug an application deployed to a remote Payara server, I am not sure how to do it. The project is a war project.
task (deploy, dependsOn: 'war', type:Exec) {
// Variable glassfishHome defined in gradle.properties
workingDir "${glassfishHome}${File.separator}bin"
if (System.properties['os.name'].toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', 'asadmin.bat'
} else {
commandLine "./asadmin"
}
args "deploy", "--force=true", "${war.archivePath}"
}
task(debug, dependsOn: 'deploy', type: JavaExec) {
// Open this page in the browser
doLast {
System.out.println(String.format("Classpath: %s", sourceSets.main.runtimeClasspath))
System.out.println(String.format("Main: %s", sourceSets.main))
// Where do I put me server address (like my.server.com:9009)?
mainClass = // what do I put here
classpath = // what do I put here
// debug true
debugOptions {
enabled = true
port = 9009
server = true
suspend = true
}
// turn off the broken dpi on my highDPI display.
jvmArgs = ["-Dsun.java2d.dpiaware=false"]
// launch the browser with the app location.
java.awt.Desktop.desktop.browse "https://${appHttpsHost}/myApp?myParam1=this&myParam2=that".toURI()
}
}
I’m not sure how you think this might be at all Gradle related.
At the point where you deployed your war to the Payara server and want to debug it, Gradle is not at all in the loop anymore.
Check in the documentation of Payara how to enable attaching a remote debugger to it and then attach your IDE to it.
This does not seem in any way Gradle related to me.
With that task, you start your application with debug option, and then attach your IDE to it.
What you want to do is, to start Payara with debug option, and then attach your IDE to it.
Again, Gradle is out of the loop here, because you do not use Gradle to start your application, but Payara.
Again, it does not use Gradle “to debug”.
Gradle just starts your application with JVM debugging enabled, then your IDE attaches to that.
You do not need a NetBeans forum, you need a Payara forum that tells you how to enable remote debugging and then maybe a NetBeans forum that tells you how to attach to the listening debugger port on the server.