Question

I'm trying to debug worklight 6.1 adapter code (java). I figured the most logical way would be to restart the imbedded liberty server in debug mode. That fails with a message:

ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
Error occurred during initialization of VM
agent library failed to init: jdwp

I followed the process documented for 6.0 at Logging and debugging Java on Worklight Server but I get the same issue there.

Was it helpful?

Solution

Ok, this is silly, but I just figured it out. You do not need to set anything for debug mode. Apparently in 6.1 this is already set. To begin debugging of your java code in the adapter you need to do the following:

  1. Create a debug configuration for a "Remote Java Application".
  2. Set the project to your worklight hybrid project
  3. I set the port to 10777. which is what jdwp was set to in the jvm.options file for the worklight server.
  4. Once you click on debug for that configuration, it will allow you to debug your adapter.

You can see the jvm.options file if you expand the Worklight Development Server definition in the Servers view. See below for an example of the contents of that file.

-Dfile.encoding=UTF-8
-Duser.language=en
-Duser.country=US
-Djava.awt.headless=true
-Dwas.debug.mode=true
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=10777
-Dcom.ibm.websphere.ras.inject.at.transform=true

Uploaded video to youtube on how to do this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top