When I try to start a WebSphere Liberty server in debug mode (to connect the Eclipse Java debugger) via:
$ ./wlp/bin/server debug MyServer
I get the following error:
Error occurred during initialization of VM
agent library failed to init: jdwp
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
and the server doesn't start.
If the jvm.options file already includes options enabling the debugger then use the
liberty start <server>
subcommand rather than:
liberty debug <server>
E.g. in my case my server had file .../usr/servers/MyServer/jvm.options with contents:
#Generated by liberty-maven-plugin
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=7777
so these options collided with the options triggered by the debug subcommand.
You can remove the jvm.options contents or file and use the debug subcommand instead.
NOTE: Reading this explanation, the error message becomes clear, but this Q&A is hopefully useful in case it didn't occur to someone that this is the solution.