Debugging MarkLogic Rest Extensions
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 1
- Joined: Fri Mar 06, 2015 12:10 pm
Debugging MarkLogic Rest Extensions
I am trying to debug MarkLogic rest extensions with the xquery debugger.
I've set up a Datasource and a connection to my local MarkLogic 7 instance.
In the datasource explorer I can open up the right rest extension.
I select my HTTP server I want to debug and enable debug on that server.
If I then fire a rest call to that server and refresh the requests I see some request that is halted by the debugger. It is not my rest extension but /MarkLogic/rest-api/endpoints/resource-service-query.xqy
I then select that request and choose Debug, the debugger perspective is opened and the beforementioned xquery file is opened twice! I can then step through that module and have my endpoint run to completion but I cannot get the debugger to stop in the actual rest extension module.
When I start the debugging session I get the following errors
Severity: warning
Description: Could not update breakpoints. They will not be in effect: The XDBC server used to send queries may not have its modules configured correctly. XDBC server name: sarepta-xcc, Modules database: sarepta-modules, Modules root: /. DBG-MODULEDNE: ns1:line(11419614729549573805, "/marklogic.rest.resource/reports/assets/resource.xqy", xs:unsignedInt("13")) -- Module not found: /marklogic.rest.resource/reports/assets/resource.xqy
When I try to set a breakpoint in the resource.xqy file for my extension I get this message in a message box:
The XDBC server used to send queries may not have its modules configured correctly. XDBC server name: sarepta-xcc, Modules database: sarepta-modules, Modules root: /. DBG-MODULEDNE: ns1:line(xs:unsignedLong("11419614729549573805"), "/marklogic.rest.resource/reports/assets/resource.xqy", 15) -- Module not found: /marklogic.rest.resource/reports/assets/resource.xqy
I also created a validation scenario with the MarkLogic connection as engine and if I open up the endpoint in the connection view and validate it with the scenario I get this error message:
System ID: /Users/pkester/Development/StandardNorway/Release_2015-02_22/Release_2015_02_22/Src/Sarepta.MarkLogic/rest-api/ext/reports.xqy
Main validation file: /Users/pkester/Development/StandardNorway/Release_2015-02_22/Release_2015_02_22/Src/Sarepta.MarkLogic/rest-api/ext/reports.xqy
Scenario name: MarkLogic XQuery
Engine name: Sarepta
Severity: error
Description: XDMP-EVALLIBMOD: xdmp:eval("xquery version "1.0-ml"; module namespace rep...", (), <options xmlns="xdmp:eval"><default-xquery-version>app-server</default-xquery-version><stat...</options>) -- Cannot evaluate library module:
Can you tell me what I'm missing here?
Thanks,
Peter
I've set up a Datasource and a connection to my local MarkLogic 7 instance.
In the datasource explorer I can open up the right rest extension.
I select my HTTP server I want to debug and enable debug on that server.
If I then fire a rest call to that server and refresh the requests I see some request that is halted by the debugger. It is not my rest extension but /MarkLogic/rest-api/endpoints/resource-service-query.xqy
I then select that request and choose Debug, the debugger perspective is opened and the beforementioned xquery file is opened twice! I can then step through that module and have my endpoint run to completion but I cannot get the debugger to stop in the actual rest extension module.
When I start the debugging session I get the following errors
Severity: warning
Description: Could not update breakpoints. They will not be in effect: The XDBC server used to send queries may not have its modules configured correctly. XDBC server name: sarepta-xcc, Modules database: sarepta-modules, Modules root: /. DBG-MODULEDNE: ns1:line(11419614729549573805, "/marklogic.rest.resource/reports/assets/resource.xqy", xs:unsignedInt("13")) -- Module not found: /marklogic.rest.resource/reports/assets/resource.xqy
When I try to set a breakpoint in the resource.xqy file for my extension I get this message in a message box:
The XDBC server used to send queries may not have its modules configured correctly. XDBC server name: sarepta-xcc, Modules database: sarepta-modules, Modules root: /. DBG-MODULEDNE: ns1:line(xs:unsignedLong("11419614729549573805"), "/marklogic.rest.resource/reports/assets/resource.xqy", 15) -- Module not found: /marklogic.rest.resource/reports/assets/resource.xqy
I also created a validation scenario with the MarkLogic connection as engine and if I open up the endpoint in the connection view and validate it with the scenario I get this error message:
System ID: /Users/pkester/Development/StandardNorway/Release_2015-02_22/Release_2015_02_22/Src/Sarepta.MarkLogic/rest-api/ext/reports.xqy
Main validation file: /Users/pkester/Development/StandardNorway/Release_2015-02_22/Release_2015_02_22/Src/Sarepta.MarkLogic/rest-api/ext/reports.xqy
Scenario name: MarkLogic XQuery
Engine name: Sarepta
Severity: error
Description: XDMP-EVALLIBMOD: xdmp:eval("xquery version "1.0-ml"; module namespace rep...", (), <options xmlns="xdmp:eval"><default-xquery-version>app-server</default-xquery-version><stat...</options>) -- Cannot evaluate library module:
Can you tell me what I'm missing here?
Thanks,
Peter
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: Debugging MarkLogic Rest Extensions
Post by alex_jitianu »
Hello Peter,
First of all, about why the debugger is not stopping in your extension module. I've looked inside the REST infrastructure and inside Modules\MarkLogic\rest-api\lib\endpoint-util.xqy I've noticed that your extension is invoked using xdmp:invoke(). Modules run using xdmp:invoke() are not picked up by the debugging process. I've reported the issue some time ago to MarkLogic and this is what they said:
As far as I can tell, The only current way to debug these extensions is to perform a debugging (like you did) just to identify the context that is passed to the module ($params and $options):
After discovering these values create an XQuery in Oxygen and run against the server something like this (you must also define the params and options):
This will start a new debugging session that you should find under the TaskServer application server. You can attach to it and debug it.
About the Could not update breakpoints. warnings. Oxygen uses an XDBC server to send queries to the HTTP server that is actually running the query. In order to successfully set breakpoints, the two servers must have the same module configuration (*modules* and *root* properties). The XDBC server is the one who's port you've given when creating the markLogic connection in Oxygen preferences. Please check if the two servers have the same module configuration and if the warning still appears after configuring them similarly. If the warning still appears than perhaps you can give me more details on how I can reproduce the issue myself. I have to say that the REST API from MarkLogic is fairly new to me.
About the validation scenario. To validate an XQuery we are using the static-check parameter with xdmp:invoke() or xdmp:eval() functions. You are not opening the module from our Data Source Explorer but directly from the file system and probably that's why xdmp:eval is being used instead of xdmp:invoke. But either way, a library module (one that has a declaration like this: module namespace eput = "http://marklogic.com/rest-api/lib/endpoint-util";) can't be evaluated/validated. You have to create an XQuery that imports that module and uses functions from it and validate that one. Inside a validation scenario you can specify a file different than the current one to be validated. So you can create a validation scenario over module.xqy and specify in it that main.xqy should be the starting point for validation. So while you are working on the module, the module is validated in the context in which it is being used.
Best regards,
Alex
First of all, about why the debugger is not stopping in your extension module. I've looked inside the REST infrastructure and inside Modules\MarkLogic\rest-api\lib\endpoint-util.xqy I've noticed that your extension is invoked using xdmp:invoke(). Modules run using xdmp:invoke() are not picked up by the debugging process. I've reported the issue some time ago to MarkLogic and this is what they said:
If you agree, I will write to MarkLogic (with you in CC) and tell them that we have a second user that reported this limitation.We have received a response on this case from our server side team. According to them, though this is working as per design, it is a design limitation. Apart from this, there is an existing RFE open "Add capability to debug a request in xdmp:invoke() and xdmp:eval()" and we have added your case to it to keep track about requests. We will change the status of this ticket to "RFE filed" and keep you informed about any changes.
As far as I can tell, The only current way to debug these extensions is to perform a debugging (like you did) just to identify the context that is passed to the module ($params and $options):
Code: Select all
xdmp:invoke($path,$params,$options)
Code: Select all
dbg:invoke($path,$params,$options)
About the Could not update breakpoints. warnings. Oxygen uses an XDBC server to send queries to the HTTP server that is actually running the query. In order to successfully set breakpoints, the two servers must have the same module configuration (*modules* and *root* properties). The XDBC server is the one who's port you've given when creating the markLogic connection in Oxygen preferences. Please check if the two servers have the same module configuration and if the warning still appears after configuring them similarly. If the warning still appears than perhaps you can give me more details on how I can reproduce the issue myself. I have to say that the REST API from MarkLogic is fairly new to me.
About the validation scenario. To validate an XQuery we are using the static-check parameter with xdmp:invoke() or xdmp:eval() functions. You are not opening the module from our Data Source Explorer but directly from the file system and probably that's why xdmp:eval is being used instead of xdmp:invoke. But either way, a library module (one that has a declaration like this: module namespace eput = "http://marklogic.com/rest-api/lib/endpoint-util";) can't be evaluated/validated. You have to create an XQuery that imports that module and uses functions from it and validate that one. Inside a validation scenario you can specify a file different than the current one to be validated. So you can create a validation scenario over module.xqy and specify in it that main.xqy should be the starting point for validation. So while you are working on the module, the module is validated in the context in which it is being used.
Best regards,
Alex
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service