Debugging MarkLogic Rest Extensions

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Posts: 2652
Joined: Tue May 17, 2005 4:01 pm

Re: Debugging MarkLogic Rest Extensions

Post by adrian » Wed May 30, 2018 1:58 pm


Note that there are some limitations/requirements with regard to breakpoints when debugging with MarkLogic in Oxygen.
First, please make sure you have read the section Using Breakpoints for Debugging Queries that Import Modules with MarkLogic from the user manual. Specifically the last paragraph:
If you get a warning that the breakpoints failed to initialize, try the following solutions:
* Check the Breakpoints view and make sure there are no older breakpoints (set on resources that are not part of the current debugging context).
* Make sure you open the modules from the context of the application server that does the debugging and place breakpoints there.
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Posts: 763
Joined: Wed Nov 16, 2005 11:11 am

Re: Debugging MarkLogic Rest Extensions

Post by alex_jitianu » Mon Jun 04, 2018 4:38 pm


Debugging a REST resource extension tends to be quite tricky. First of all the REST extension is loaded dynamically which means that its module URI is not known to the server at the beginning of the debugging session. To add breakpoints we use MarkLogic's API dbg:break() and dbg:line(). These functions can add breakpoints only on already loaded modules.

To go around this limitation, here is what you can do:

1. In Oxygen, remove all the breakpoints you have already added.

2. Before starting the debugging session, go in Oxygen to File->Open URL and open:

Code: Select all


Code: Select all

{HOST.NAME}         = the HOST name as it was configured in the MarkLogic connection inside Oxygen
{DATA.SOURCE} = the Name of the ML datasource as it has created inside Oxygen's preferences
{CONNECTION.NAME} = The name of the MarkLogic connection (configured inside Oxygen)
3. Search for the function extut:call-service() and add some breakpoint on it.

4. Start the debugging process and hit "Run" . The debugger should stop at the previously added breakpoints.

5. Do some "Step In" until the extension is invoked and your module is opened by Oxygen.

Unfortunately, another limitation that I discovered is that you can't add breakpoints inside your extension because when we use the aforementioned dbg:line() we always get the error: "Line number greater than lines in module". This means that you will have to rely on Step In/Out/Over actions to navigate the query.

When I've discovered the issue, I've also reported it to MarkLogic ( I'm sorry that things are more tedious then they should be!

Best regards,

Post Reply