open-libertyliberty-maven-plugin

How do I start a Liberty server in dev mode in a suspended mode waiting for the debugger to attach?


Using the Liberty Maven Plugin, running in dev mode, I'm trying to start the Liberty server in suspended mode by setting the env var: WLP_DEBUG_SUSPEND=y. The server does launch listening on port 7777 for a debugger attachment but without waiting for the debugger, i.e. not in suspended mode.

My command is:

mvn liberty:dev -Dliberty.env.WLP_DEBUG_SUSPEND=y

Solution

  • The Liberty Maven Plugin purposely overrides the WLP_DEBUG_SUSPEND setting in "dev mode" in a way that prevents this type of usage.

    As an alternative, you can launch Liberty via the "run" goal, and set the debugger JVM options including the suspend=y debugger config:

    mvn liberty:run -Dliberty.jvm.debug='-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0.0.0.0:7777'
    

    The run goal isn't the same as "dev mode" since it doesn't provide a "watcher" to update the server when pom.xml, application source, test, and config files are updated (like dev mode). But it does provide a quick way to launch Liberty with Maven with a single command so it can be a useful tool to be aware of.