How do I start a Liberty server in debug mode in the background with the liberty-maven-plugin?

3.9k Views Asked by At

Use Case

The liberty-maven-plugin has a debug goal which allows you to start the server in debug mode, but in the foreground.

Often when wanting to attach the debugger, this is all you'd need. You can execute tests separately somehow or via other goals launched from another shell.

But the debug goal, like the run goal, runs in the foreground and blocks until the server process completes.

If I want to continue to the next phase of my build, e.g. on to run integration tests, it could help to configure a start goal to start the server in debug mode, in the background, and continue on.

1

There are 1 best solutions below

0
On BEST ANSWER

Use: src/test/resources/jvm.options

In src/test/resources/jvm.options, for example:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=7777

This is the default value for the <jvmOptionsFile> configuration parameter (described here), so of course you could configure a different location if desired.

Note:

Though an alternative might appear to be to use the <jvmOptions> configuration, it does not work well with the commas (',') embedded in this value.

Warning:

You may be expecting a message from the starting JVM:

Listening for transport dt_socket at address: 7777

However you will not see this from your Maven execution log, it actually appears in the console.log file of the configured server. So the Maven execution will just pause at the point of logging message:

[INFO] Starting server defaultServer.

If you fail to connect in time you'll see:

[INFO] Server defaultServer start failed. Check server logs for details.