1

I've got several microservices projects that I'm developing using the Thorntail framework. I'm writing my code using Eclipse. In the past, I've done all of my development using the Wildfly app server, and Eclipse made debugging these apps dead simple. Right Click->Debug As->Debug On Server. Done. Now that I'm using Thorntail, I'm not quite sure how to do it.

From the command line, I would start my Thorntail projects using:

mvn thorntail:run -Dthorntail.useUberJar # Project 1
mvn thorntail:run -Dthorntail.useUberJar -Dthorntail.port.offset=1000 # Project 2

That gets everything up and running, and listening on ports 8080 and 9080. However, the services are not in debug mode and I didn't launch these through Eclipse.

I know I can Right Click->Debug As->Maven Build... and then create a new debug configuration. I've done so, with my goals corresponding to the mvn commands above. However, when I do so no debugger is automatically attached, so breakpoints and such don't work. I'm sure I'm missing a step somewhere, but this is functionality I haven't tried to use before so I'm lost. Any recommendations?

2 Answers 2

3

The mvn thorntail:run accepts a system property thorntail.debug.port with a port number. For example, if you run

mvn thorntail:run -Dthorntail.useUberJar -Dthorntail.debug.port=5005

the Java process will wait for remote debugger connection and only then will it continue.

I don't use Eclipse, but I'm pretty sure configuring a remote debugging session isn't hard.

2

Execute the uberjar with the following parameters. Ensure that all the parameters are specified before the name of the uberjar on the line.

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=$PORT_NUMBER -jar $UBERJAR_FILENAME

$PORT_NUMBER is an unused port number of your choice. Remember this number for the remote debugger configuration.

$UBERJAR_FILENAME is the uberjar.

suspend=y ensures that JVM will pause and wait for remote debugger connection before it starts the application.

To remote debugging it using Eclipse IDE you have to open Eclipse, open source code of the targeted application and create a debug configuration ("Remote Java Application") by specifying the targeted host and port. After this, hit "Debug" button and proceed with the remote debugging.

3
  • Should this work with hollow jar? I always get "Connection reset" trying to debug with Intellij. Jun 19, 2019 at 10:39
  • With uber jar "target/myapp-thorntail.jar" works fine. Be careful with parameter position.
    – Dinsdale
    Nov 29, 2019 at 9:37
  • Thorntail Debug here: access.redhat.com/documentation/en-us/…. Apr 5, 2020 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.