Page 1 of 1

Debug Xquery rest-api in MarkLogic

Posted: Sat Jan 07, 2017 9:29 pm
by vkdev
Hi
I have a trial enterprise version of Oxygen on my windows computer. I have configured to connect to MarkLogic server( remote server). I have used the AppServer port in the port property while configuringin oxygen.

The server has some xquery files that are modules
When I look at the datasource explorer, I see the xquery files under the structure- http server/modules/marklogic.rest.resource/tasklist/assets/resource.xqy

I want to debug this file. I set up breakpoint. I have a web application hosted on a different server. A rest call is made that makes a get/post call that invokes the xquery.
the url called is http://marklogicserver/v1/resources/tasklist


Problem- the debug point is not hit.
I see an error- Could not initialize the server debugging session. Reason: Error encountered in module: /eval : XDMP-EVALLIBMOD: dbg:invoke("/marklogic.rest.resource/tasklist/assets/resource.xqy", (), <options xmlns="xdmp:eval"><default-xquery-version>app-server</default-xquery-version></options>) -- Cannot evaluate library module: /marklogic.rest.resource/tasklist/assets/resource.xqy

Please help.

Re: Debug Xquery rest-api in MarkLogic

Posted: Tue Jan 10, 2017 10:53 am
by alex_jitianu
Hello,
Could not initialize the server debugging session. Reason: Error encountered in module: /eval : XDMP-EVALLIBMOD: dbg:invoke("/marklogic.rest.resource/tasklist/assets/resource.xqy"
This error message suggests that you've tried to start the debugging session directly from Oxygen, on resource.xqy. In your case, the debugging process involves a few steps:
1. Inside Oxygen's Data Source Explorer, identify the HTTP AppServer that will serve the request for "http://marklogicserver/v1/resources/tasklist" and put it in debug-mode (by choosing Enable debug mode from the contextual menu).
2. Go into your Web application and initiate the request
3. Return to Oxygen, and expand the HTTP App Server. Inside the Requests container you will see the previously initiated request. From the contextual menu choose Debug.

It is very important that the XDBC AppServer configured inside Oxygen (we use this to control the debugging session) has the same Modules configuration as the HTTP App Server (the one actually executing your request). If this requirement is not fulfill then breakpoints will fail. Please see the "Debug mode" chapter from out MarkLogic demonstration for more details.

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Tue Jan 10, 2017 12:55 pm
by vkdev
Alex
Many thanks for replying. Now when i debug the http request, it goes in debug mode and the first file being debugged is a xquery library file in MarkLogic called MarkLogic/rest-api/endpoints/resource-service-query.xqy. It completes the debugging but does not hit the breakpoint in my rest api extension xquery file (tasklist.xqy)
it opens my tasklist xqquery file but displays as blank.

Re: Debug Xquery rest-api in MarkLogic

Posted: Tue Jan 10, 2017 4:52 pm
by alex_jitianu
Hello,

Does the XDBC AppServer configured inside Oxygen have the same Modules configuration as the HTTP App Server? You can verify this inside MarkLogic's admin interface (an HTTP server that usually runs on port 8001). Identify the AppServers inside the Configure/Groups section. Identify the two AppServers by Port and compare their Modules and Root settings. The XDBC must have the same configuration as the HTTP one.

An XQuery like this would also give you this information:

Code: Select all

for $s in xdmp:servers()
return xdmp:server-status(xdmp:host(), $s)
Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Tue Jan 10, 2017 5:55 pm
by vkdev
Yes Alex. The XDBC server(port 8013) and the HTTP server (port 8011) both have / as root and both use the same was_audit_modules as modules database.

Re: Debug Xquery rest-api in MarkLogic

Posted: Wed Jan 11, 2017 11:31 am
by alex_jitianu
Hi,
the first file being debugged is a xquery library file in MarkLogic called MarkLogic/rest-api/endpoints/resource-service-query.xqy
If you use Step Into/Over/Out do you eventually end up inside tasklist.xqy (the module)? What MarkLogic version and Oxygen version are you using?
it opens my tasklist xqquery file but displays as blank.
The debug process opens this automatically? And you see just an empty editor, without content? When you open tasklist.xqy manually from the Data Source Explorer please copy its URL (invoke the contextual menu on the editor tab and choose "Copy location"). When the empty editor is open copy its URL too. Please send me the two of them so I can compare them.

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Wed Jan 11, 2017 5:36 pm
by vkdev
Alex

I am using oxygen editor 18.1 on Windows 7 64 bit and Java version is 1.8
Marklogic version is 8.1

when the debugger opens the tasklist automatically and its blank, the location is this-
oxygen://im4w193.svr.us.jpmchase.net/MarkLogicXcc$bpmn/13352283577776606320//$/v1/resources/tasklist $/v1/resources/tasklist.
There is no file extension on this blank file.

The data source explorer does not list a file called tasklist.xqy. This file is listed as resource.xqy under
oxygen://im4w193.svr.us.jpmchase.net/MarkLogicXcc$bpmn/13352283577776606320//$/marklogic.rest.resource/tasklist/assets/resource.xqy$/marklogic.rest.resource/tasklist/assets/resource.xqy

Is there any debugger transformation required?

Re: Debug Xquery rest-api in MarkLogic

Posted: Wed Jan 11, 2017 5:58 pm
by vkdev
Many times I encounter this error-
I/O error on GET request for "http://im4w193.svr.us.jpmchase.net:8011 ... s/tasklist": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out
This error is thrown by the tomcat app server that makes the http rest call.
What must be the different values on the MarkLogic app server and MarkLogic XDBC server for these -
request timeout, session timeout, keep alive timeout, max timeout, default time limit.
right now I have all of these set to 4294967295.

Re: Debug Xquery rest-api in MarkLogic

Posted: Thu Jan 12, 2017 1:41 pm
by alex_jitianu
Hi,

First of all, thank you for taking the time to get to the bottom of this issue. Can you please run this query and send me the result? Before doing that, please replace the name of the two servers specified at the beginning, in the two variables. To run it you can use the "XPath/XQuery Builder" (accessible from Window->Show View). Don't forget to select the MarkLogic connection as the engine.

Code: Select all

let $httpServerName := "bill"
let $xdbcServerName := "billXDBC"

let $xdbcStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($xdbcServerName))

let $httpStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($httpServerName))

return (
$xdbcStatus,
$httpStatus,
for $reqSt in $httpStatus//*:request-status
where $reqSt/*:debugging-status/text() = "attached"
return dbg:stack($reqSt/*:request-id)
)
You can post the log here or you can send it to support@oxygenxml.com

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Thu Jan 12, 2017 2:36 pm
by vkdev

Code: Select all

<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>625740577222718969</server-id>
<server-name>waas-audit-xdbc-server</server-name>
<host-id>12995321406427516165</host-id>
<server-kind>xdbc-server</server-kind>
<enabled>true</enabled>
<port>8013</port>
<root>/</root>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>2</threads>
<max-threads>32</max-threads>
<request-timeout>0</request-timeout>
<keep-alive-timeout>4294967295</keep-alive-timeout>
<session-timeout>4294967295</session-timeout>
<max-time-limit>4294967295</max-time-limit>
<default-time-limit>4294967295</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>digestbasic</authentication>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-12T06:35:02.205-05:00</current-time>
<request-statuses>
<request-status>
<request-id>1634940833500808372</request-id>
<server-id>625740577222718969</server-id>
<host-id>12995321406427516165</host-id>
<transaction-id>3650326747957274728</transaction-id>
<canceled>false</canceled>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<root>/</root>
<request-kind>eval</request-kind>
<request-text>let $httpServerName := "WaaS_Audit_Server"
let $xdbcServerName := "waas-audit-xdbc-server"

let $xdbcStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($xdbcServerName))

let $httpStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($httpServerName))

return (
$xdbcStatus,
$httpStatus,
for $reqSt in $httpStatus//*:request-status
where $reqSt/*:debugging-status/text() = "attached"
return dbg:stack($reqSt/*:request-id)
) </request-text>
<update>false</update>
<start-time>2017-01-12T06:35:02.19-05:00</start-time>
<time-limit>4294967295</time-limit>
<max-time-limit>4294967295</max-time-limit>
<user>3139692216150066155</user>
<client-address>10.6.28.181</client-address>
<trigger-depth>0</trigger-depth>
<expanded-tree-cache-hits>0</expanded-tree-cache-hits>
<expanded-tree-cache-misses>0</expanded-tree-cache-misses>
<request-state>running</request-state>
<profiling-allowed>true</profiling-allowed>
<profiling-enabled>false</profiling-enabled>
<debugging-allowed>true</debugging-allowed>
<debugging-status>detached</debugging-status>
<retry-count>0</retry-count>
</request-status>
</request-statuses>
<request-rate>0.08025247</request-rate>
<expanded-tree-cache-hits>76</expanded-tree-cache-hits>
<expanded-tree-cache-misses>57</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>7</fs-program-cache-hits>
<fs-program-cache-misses>7</fs-program-cache-misses>
<db-program-cache-hits>27209</db-program-cache-hits>
<db-program-cache-misses>27209</db-program-cache-misses>
<fs-main-module-seq-cache-hits>7</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>7</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>28</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>28</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>484</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>484</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>2</db-lib-module-cache-hits>
<db-lib-module-cache-misses>2</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<request-time>0.0003555556</request-time>
</server-status>
<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>3049705919618181635</server-id>
<server-name>WaaS_Audit_Server</server-name>
<host-id>12995321406427516165</host-id>
<server-kind>http-server</server-kind>
<enabled>true</enabled>
<port>8011</port>
<root>/</root>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>1</threads>
<max-threads>32</max-threads>
<request-timeout>4294967295</request-timeout>
<keep-alive-timeout>0</keep-alive-timeout>
<session-timeout>4294967295</session-timeout>
<static-expires>3600</static-expires>
<max-time-limit>4294967295</max-time-limit>
<default-time-limit>4294967295</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>basic</authentication>
<default-user>10306463041007996463</default-user>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-12T06:35:02.205-05:00</current-time>
<request-statuses/>
<request-rate>0</request-rate>
<expanded-tree-cache-hits>47</expanded-tree-cache-hits>
<expanded-tree-cache-misses>9</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>30</fs-program-cache-hits>
<fs-program-cache-misses>30</fs-program-cache-misses>
<db-program-cache-hits>2</db-program-cache-hits>
<db-program-cache-misses>2</db-program-cache-misses>
<env-program-cache-hits>0</env-program-cache-hits>
<env-program-cache-misses>0</env-program-cache-misses>
<fs-main-module-seq-cache-hits>11</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>11</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>0</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>0</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>1562</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>1562</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>8</db-lib-module-cache-hits>
<db-lib-module-cache-misses>8</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<error-handler>/MarkLogic/rest-api/error-handler.xqy</error-handler>
<url-rewriter>/MarkLogic/rest-api/rewriter.xml</url-rewriter>
<request-time>0</request-time>
</server-status>

Re: Debug Xquery rest-api in MarkLogic

Posted: Thu Jan 12, 2017 4:27 pm
by alex_jitianu
Hi,

One thing I forgot to mention. Please run this query during the debugging process, just after the step that opens the blank "tasklist" editor.

Thanks!
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Thu Jan 12, 2017 5:53 pm
by vkdev
Alex-
I don't get to see the blank file everytime. Today I have tried many times and unable to bring that blank page up.
The debugger seems to jump. Sometimes it hits the host-model.xqy, sometimes it stops at resource-service-query.xqy.
It completed the execution.

then I ran the script and here is the output. Not sure if this will help.

Code: Select all

<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>625740577222718969</server-id>
<server-name>waas-audit-xdbc-server</server-name>
<host-id>12995321406427516165</host-id>
<server-kind>xdbc-server</server-kind>
<enabled>true</enabled>
<port>8013</port>
<root>/</root>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>3</threads>
<max-threads>32</max-threads>
<request-timeout>0</request-timeout>
<keep-alive-timeout>4294967295</keep-alive-timeout>
<session-timeout>4294967295</session-timeout>
<max-time-limit>4294967295</max-time-limit>
<default-time-limit>4294967295</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>digestbasic</authentication>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-12T09:50:36.707-05:00</current-time>
<request-statuses>
<request-status>
<request-id>6041377219635797433</request-id>
<server-id>625740577222718969</server-id>
<host-id>12995321406427516165</host-id>
<transaction-id>1198349345506073625</transaction-id>
<canceled>false</canceled>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<root>/</root>
<request-kind>eval</request-kind>
<request-text>let $httpServerName := "WaaS_Audit_Server"
let $xdbcServerName := "waas-audit-xdbc-server"

let $xdbcStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($xdbcServerName))

let $httpStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($httpServerName))

return (
$xdbcStatus,
$httpStatus,
for $reqSt in $httpStatus//*:request-status
where $reqSt/*:debugging-status/text() = "attached"
return dbg:stack($reqSt/*:request-id)
) </request-text>
<update>false</update>
<start-time>2017-01-12T09:50:36.691-05:00</start-time>
<time-limit>4294967295</time-limit>
<max-time-limit>4294967295</max-time-limit>
<user>3139692216150066155</user>
<client-address>10.47.205.9</client-address>
<trigger-depth>0</trigger-depth>
<expanded-tree-cache-hits>0</expanded-tree-cache-hits>
<expanded-tree-cache-misses>0</expanded-tree-cache-misses>
<request-state>running</request-state>
<profiling-allowed>true</profiling-allowed>
<profiling-enabled>false</profiling-enabled>
<debugging-allowed>true</debugging-allowed>
<debugging-status>detached</debugging-status>
<retry-count>0</retry-count>
</request-status>
</request-statuses>
<request-rate>11.31301</request-rate>
<expanded-tree-cache-hits>0</expanded-tree-cache-hits>
<expanded-tree-cache-misses>0</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>1</fs-program-cache-hits>
<fs-program-cache-misses>1</fs-program-cache-misses>
<db-program-cache-hits>1623</db-program-cache-hits>
<db-program-cache-misses>1623</db-program-cache-misses>
<fs-main-module-seq-cache-hits>1</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>1</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>0</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>0</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>0</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>0</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>0</db-lib-module-cache-hits>
<db-lib-module-cache-misses>0</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<request-time>0.1209383</request-time>
</server-status>
<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>3049705919618181635</server-id>
<server-name>WaaS_Audit_Server</server-name>
<host-id>12995321406427516165</host-id>
<server-kind>http-server</server-kind>
<enabled>true</enabled>
<port>8011</port>
<root>/</root>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>1</threads>
<max-threads>32</max-threads>
<request-timeout>4294967295</request-timeout>
<keep-alive-timeout>0</keep-alive-timeout>
<session-timeout>4294967295</session-timeout>
<static-expires>3600</static-expires>
<max-time-limit>4294967295</max-time-limit>
<default-time-limit>4294967295</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>basic</authentication>
<default-user>10306463041007996463</default-user>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-12T09:50:36.707-05:00</current-time>
<request-statuses/>
<request-rate>0.00761446</request-rate>
<expanded-tree-cache-hits>11</expanded-tree-cache-hits>
<expanded-tree-cache-misses>3</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0.05592549</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>5</fs-program-cache-hits>
<fs-program-cache-misses>5</fs-program-cache-misses>
<db-program-cache-hits>0</db-program-cache-hits>
<db-program-cache-misses>0</db-program-cache-misses>
<env-program-cache-hits>0</env-program-cache-hits>
<env-program-cache-misses>0</env-program-cache-misses>
<fs-main-module-seq-cache-hits>1</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>1</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>0</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>0</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>121</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>121</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>1</db-lib-module-cache-hits>
<db-lib-module-cache-misses>1</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<error-handler>/MarkLogic/rest-api/error-handler.xqy</error-handler>
<url-rewriter>/MarkLogic/rest-api/rewriter.xml</url-rewriter>
<request-time>0.3643</request-time>
</server-status>

Re: Debug Xquery rest-api in MarkLogic

Posted: Fri Jan 13, 2017 12:44 pm
by alex_jitianu
Hi,

From the log, I see that the HTTP Server (WaaS_Audit_Server ) is not running any requests. It should have presented the request you started from the browser, when you accessed the entry point query. Did you put it in "Debug mode" from the Data Source Explorer contextual menu, before making the request? If you run dbg:connected() what result do you get?

Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Fri Jan 13, 2017 4:58 pm
by vkdev
the app server is enabled in debug mode.
here is the output while the debugger is running.

Code: Select all

<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>625740577222718969</server-id>
<server-name>waas-audit-xdbc-server</server-name>
<host-id>12995321406427516165</host-id>
<server-kind>xdbc-server</server-kind>
<enabled>true</enabled>
<port>8013</port>
<root>/</root>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>2</threads>
<max-threads>32</max-threads>
<request-timeout>0</request-timeout>
<keep-alive-timeout>4294967295</keep-alive-timeout>
<session-timeout>4294967295</session-timeout>
<max-time-limit>4294967295</max-time-limit>
<default-time-limit>4294967295</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>digestbasic</authentication>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-13T08:46:30.809-05:00</current-time>
<request-statuses>
<request-status>
<request-id>10651549685608968909</request-id>
<server-id>625740577222718969</server-id>
<host-id>12995321406427516165</host-id>
<transaction-id>888058986306495823</transaction-id>
<canceled>false</canceled>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<root>/</root>
<request-kind>eval</request-kind>
<request-text>let $httpServerName := "WaaS_Audit_Server"
let $xdbcServerName := "waas-audit-xdbc-server"

let $xdbcStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($xdbcServerName))

let $httpStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($httpServerName))

return (
$xdbcStatus,
$httpStatus,
for $reqSt in $httpStatus//*:request-status
where $reqSt/*:debugging-status/text() = "attached"
return dbg:stack($reqSt/*:request-id)
) </request-text>
<update>false</update>
<start-time>2017-01-13T08:46:30.793-05:00</start-time>
<time-limit>4294967295</time-limit>
<max-time-limit>4294967295</max-time-limit>
<user>3139692216150066155</user>
<client-address>10.47.205.9</client-address>
<trigger-depth>0</trigger-depth>
<expanded-tree-cache-hits>0</expanded-tree-cache-hits>
<expanded-tree-cache-misses>0</expanded-tree-cache-misses>
<request-state>running</request-state>
<profiling-allowed>true</profiling-allowed>
<profiling-enabled>false</profiling-enabled>
<debugging-allowed>true</debugging-allowed>
<debugging-status>detached</debugging-status>
<retry-count>0</retry-count>
</request-status>
</request-statuses>
<request-rate>0.5902176</request-rate>
<expanded-tree-cache-hits>0</expanded-tree-cache-hits>
<expanded-tree-cache-misses>21</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>3</fs-program-cache-hits>
<fs-program-cache-misses>3</fs-program-cache-misses>
<db-program-cache-hits>6675</db-program-cache-hits>
<db-program-cache-misses>6675</db-program-cache-misses>
<fs-main-module-seq-cache-hits>2</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>2</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>4</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>4</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>241</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>241</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>0</db-lib-module-cache-hits>
<db-lib-module-cache-misses>0</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<request-time>0.01276923</request-time>
</server-status>
<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>3049705919618181635</server-id>
<server-name>WaaS_Audit_Server</server-name>
<host-id>12995321406427516165</host-id>
<server-kind>http-server</server-kind>
<enabled>true</enabled>
<port>8011</port>
<root>/</root>
<modules>13352283577776606320</modules>
<database>6241034363477649215</database>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>1</threads>
<max-threads>32</max-threads>
<request-timeout>4294967295</request-timeout>
<keep-alive-timeout>0</keep-alive-timeout>
<session-timeout>4294967295</session-timeout>
<static-expires>3600</static-expires>
<max-time-limit>4294967295</max-time-limit>
<default-time-limit>4294967295</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>basic</authentication>
<default-user>10306463041007996463</default-user>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-13T08:46:30.809-05:00</current-time>
<request-statuses/>
<request-rate>0</request-rate>
<expanded-tree-cache-hits>8</expanded-tree-cache-hits>
<expanded-tree-cache-misses>6</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0.1448393</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0.04827976</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>43</fs-program-cache-hits>
<fs-program-cache-misses>43</fs-program-cache-misses>
<db-program-cache-hits>0</db-program-cache-hits>
<db-program-cache-misses>0</db-program-cache-misses>
<env-program-cache-hits>0</env-program-cache-hits>
<env-program-cache-misses>0</env-program-cache-misses>
<fs-main-module-seq-cache-hits>19</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>19</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>0</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>0</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>2920</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>2920</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>3</db-lib-module-cache-hits>
<db-lib-module-cache-misses>3</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<error-handler>/MarkLogic/rest-api/error-handler.xqy</error-handler>
<url-rewriter>/MarkLogic/rest-api/rewriter.xml</url-rewriter>
<request-time>372.9417</request-time>
</server-status>

Re: Debug Xquery rest-api in MarkLogic

Posted: Mon Jan 16, 2017 12:04 pm
by alex_jitianu
Hi,

The HTTP app server (named WaaS_Audit_Server) doesn't look to be inside a debugging session because it has no running requests (<request-statuses> container element). Here is a log that I've generated while an HTTP app server (in my case named "bill") was in debug mode. Please not its <request-statuses> element as well as the <stack> element in which you can see detailed information about the debugged request.

Code: Select all

<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>13636873921384712747</server-id>
<server-name>billXDBC</server-name>
<host-id>9330967645972548850</host-id>
<server-kind>xdbc-server</server-kind>
<enabled>true</enabled>
<port>8050</port>
<root>/opt/MarkLogic/bill/</root>
<modules>0</modules>
<database>13536649101512810662</database>
<ssl-certificate-template>0</ssl-certificate-template>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>1</threads>
<max-threads>32</max-threads>
<request-timeout>30</request-timeout>
<keep-alive-timeout>5</keep-alive-timeout>
<session-timeout>3600</session-timeout>
<max-time-limit>3600</max-time-limit>
<default-time-limit>600</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<collation>http://marklogic.com/collation/</collation>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>digest</authentication>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-16T10:06:33.257654+02:00</current-time>
<request-statuses>
<request-status>
<request-id>13817609308442004752</request-id>
<server-id>13636873921384712747</server-id>
<host-id>9330967645972548850</host-id>
<transaction-id>16581884242119500168</transaction-id>
<canceled>false</canceled>
<modules>0</modules>
<database>13536649101512810662</database>
<root>/opt/MarkLogic/bill/</root>
<request-kind>eval</request-kind>
<request-text>let $httpServerName := "bill"
let $xdbcServerName := "billXDBC"

let $xdbcStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($xdbcServerName))

let $httpStatus := xdmp:server-status(
xdmp:host(),
xdmp:server($httpServerName))

return (
$xdbcStatus,
$httpStatus,
for $reqSt in $httpStatus//*:request-status
where $reqSt/*:debugging-status/text() = "attached"
return dbg:stack($reqSt/*:request-id)
) </request-text>
<update>false</update>
<start-time>2017-01-16T10:06:33.257443+02:00</start-time>
<time-limit>600</time-limit>
<max-time-limit>3600</max-time-limit>
<user>12195789764685656724</user>
<client-address>10.0.0.128</client-address>
<trigger-depth>0</trigger-depth>
<expanded-tree-cache-hits>0</expanded-tree-cache-hits>
<expanded-tree-cache-misses>0</expanded-tree-cache-misses>
<request-state>running</request-state>
<profiling-allowed>true</profiling-allowed>
<profiling-enabled>false</profiling-enabled>
<debugging-allowed>true</debugging-allowed>
<debugging-status>detached</debugging-status>
<retry-count>0</retry-count>
</request-status>
</request-statuses>
<request-rate>0.1455906</request-rate>
<expanded-tree-cache-hits>8</expanded-tree-cache-hits>
<expanded-tree-cache-misses>1</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>1150</fs-program-cache-hits>
<fs-program-cache-misses>1150</fs-program-cache-misses>
<db-program-cache-hits>0</db-program-cache-hits>
<db-program-cache-misses>0</db-program-cache-misses>
<fs-main-module-seq-cache-hits>0</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>0</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>0</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>0</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>0</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>0</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>0</db-lib-module-cache-hits>
<db-lib-module-cache-misses>0</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<request-time>0</request-time>
</server-status>
<server-status xmlns="http://marklogic.com/xdmp/status/server">
<server-id>10443398424232950899</server-id>
<server-name>bill</server-name>
<host-id>9330967645972548850</host-id>
<server-kind>http-server</server-kind>
<enabled>true</enabled>
<port>8060</port>
<root>/opt/MarkLogic/bill/</root>
<modules>0</modules>
<database>13536649101512810662</database>
<ssl-certificate-template>0</ssl-certificate-template>
<last-login>0</last-login>
<display-last-login>false</display-last-login>
<backlog>512</backlog>
<threads>1</threads>
<max-threads>32</max-threads>
<request-timeout>30</request-timeout>
<keep-alive-timeout>5</keep-alive-timeout>
<session-timeout>3600</session-timeout>
<static-expires>3600</static-expires>
<max-time-limit>3600</max-time-limit>
<default-time-limit>600</default-time-limit>
<max-inference-size>500</max-inference-size>
<default-inference-size>100</default-inference-size>
<collation>http://marklogic.com/collation/</collation>
<multi-version-concurrency-control>contemporaneous</multi-version-concurrency-control>
<distribute-timestamps>fast</distribute-timestamps>
<authentication>digest</authentication>
<default-user>10306463041007996463</default-user>
<privilege>0</privilege>
<concurrent-request-limit>0</concurrent-request-limit>
<default-xquery-version>1.0-ml</default-xquery-version>
<current-time>2017-01-16T10:06:33.257977+02:00</current-time>
<request-statuses>
<request-status>
<request-id>14015442045018620209</request-id>
<server-id>10443398424232950899</server-id>
<host-id>9330967645972548850</host-id>
<transaction-id>9159454276841367826</transaction-id>
<canceled>false</canceled>
<modules>0</modules>
<database>13536649101512810662</database>
<root>/opt/MarkLogic/bill/</root>
<request-kind>invoke</request-kind>
<request-text>/displayScene.xqy</request-text>
<update>false</update>
<start-time>2017-01-16T10:05:32.612296+02:00</start-time>
<time-limit>600</time-limit>
<max-time-limit>3600</max-time-limit>
<user>12195789764685656724</user>
<client-address>10.0.0.18</client-address>
<trigger-depth>0</trigger-depth>
<expanded-tree-cache-hits>4</expanded-tree-cache-hits>
<expanded-tree-cache-misses>0</expanded-tree-cache-misses>
<request-state>stopped</request-state>
<profiling-allowed>true</profiling-allowed>
<profiling-enabled>false</profiling-enabled>
<debugging-allowed>true</debugging-allowed>
<debugging-status>attached</debugging-status>
<retry-count>0</retry-count>
<expr-id>4447017225726421219</expr-id>
<where-stopped>begin</where-stopped>
</request-status>
</request-statuses>
<request-rate>0.001385078</request-rate>
<expanded-tree-cache-hits>311</expanded-tree-cache-hits>
<expanded-tree-cache-misses>89</expanded-tree-cache-misses>
<expanded-tree-cache-hit-rate>0.02294407</expanded-tree-cache-hit-rate>
<expanded-tree-cache-miss-rate>0</expanded-tree-cache-miss-rate>
<fs-program-cache-hits>12</fs-program-cache-hits>
<fs-program-cache-misses>12</fs-program-cache-misses>
<db-program-cache-hits>0</db-program-cache-hits>
<db-program-cache-misses>0</db-program-cache-misses>
<env-program-cache-hits>0</env-program-cache-hits>
<env-program-cache-misses>0</env-program-cache-misses>
<fs-main-module-seq-cache-hits>8</fs-main-module-seq-cache-hits>
<fs-main-module-seq-cache-misses>8</fs-main-module-seq-cache-misses>
<db-main-module-seq-cache-hits>0</db-main-module-seq-cache-hits>
<db-main-module-seq-cache-misses>0</db-main-module-seq-cache-misses>
<fs-lib-module-cache-hits>4</fs-lib-module-cache-hits>
<fs-lib-module-cache-misses>4</fs-lib-module-cache-misses>
<db-lib-module-cache-hits>0</db-lib-module-cache-hits>
<db-lib-module-cache-misses>0</db-lib-module-cache-misses>
<hosts/>
<output-sgml-character-entities>none</output-sgml-character-entities>
<output-encoding>UTF-8</output-encoding>
<error-handler/>
<url-rewriter/>
<request-time>0</request-time>
</server-status>
<stack xmlns="http://marklogic.com/xdmp/debug">
<expr>
<expr-id>4447017225726421219</expr-id>
<expr-source>if ($x/parent::PLAY) then <span><h1>{ passthru($x) }</h1><p align="right">by William Shakespeare</p></span> else if ($x/parent::PERSONAE) then let $fname := xdmp:get-request-field("fname", fn:string(fn:base-uri($x))) return <span><ul><li><a href="{ fn:concat("displayScene.xqy?fname=", $fname, "&amp;act=1&amp;", if (fn:exists(fn:doc($fname)/PLAY/ACT[1]/PROLOGUE)) then "prologue=true" else "scene=1") }">ACT I</a></li><li><a href="{ fn:concat("displayScene.xqy?fname=", xdmp:get-request-field("fname", fn:string(xdmp:node-uri($x))), "&amp;act=2&amp;scene=1") }">ACT II</a></li><li><a href="{ fn:concat("displayScene.xqy?fname=", xdmp:get-request-field("fname", fn:string(xdmp:node-uri($x))), "&amp;act=3&amp;scene=1") }">ACT III</a></li><li><a href="{ fn:concat("displayScene.xqy?fname=", xdmp:get-request-field("fname", fn:string(xdmp:node-uri($x))), "&amp;act=4&amp;scene=1") }">ACT IV</a></li><li><a href="{ fn:concat("displayScene.xqy?fname=", xdmp:get-request-field("fname", fn:string(xdmp:node-uri($x))), "&amp;act=5&amp;scene=1") }">ACT V</a></li></ul><h3><a id="PERSONAE"/>{ passthru($x) }</h3></span> else if ($x/parent::ACT) then <h2><a id="{ fn:string-join(fn:tokenize(fn:normalize-space(fn:string-join($x/text(), "")), "\s+"), "") }"/>{ passthru($x) }</h2> else if ($x/parent::SCENE) then <h3><a id="{ xdmp:base64-encode(xdmp:describe($x)) }"/>{ passthru($x) }</h3> else if ($x/parent::PROLOGUE) then <h3><a id="{ xdmp:base64-encode(xdmp:describe($x)) }"/>{ passthru($x) }</h3> else if ($x/parent::EPILOGUE) then <h3><a id="{ xdmp:base64-encode(xdmp:describe($x)) }"/>{ passthru($x) }</h3> else <h1>{ passthru($x) }</h1></expr-source>
<uri>/display-lib.xqy</uri>
<location><database>0</database><uri>/opt/MarkLogic/bill/display-lib.xqy</uri></location>
<line>83</line>
<column>0</column>
<global-variables/>
<external-variables/>
</expr>
<frame>
<uri>/display-lib.xqy</uri>
<location><database>0</database><uri>/opt/MarkLogic/bill/display-lib.xqy</uri></location>
<line>83</line>
<column>0</column>
<operation>title(fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE/TITLE)</operation>
<global-variables/>
<external-variables/>
<variables>
<variable>
<name xmlns="http://marklogic.com/bill/display">x</name>
<prefix/>
<value>fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE/TITLE</value>
</variable>
</variables>
</frame>
<frame>
<uri>/display-lib.xqy</uri>
<location><database>0</database><uri>/opt/MarkLogic/bill/display-lib.xqy</uri></location>
<line>43</line>
<column>0</column>
<operation>dispatch(fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE/TITLE)</operation>
<global-variables/>
<external-variables/>
<variables>
<variable>
<name xmlns="http://marklogic.com/bill/display">x</name>
<prefix/>
<value>fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE/TITLE</value>
</variable>
</variables>
</frame>
<frame>
<uri>/display-lib.xqy</uri>
<location><database>0</database><uri>/opt/MarkLogic/bill/display-lib.xqy</uri></location>
<line>32</line>
<column>0</column>
<operation>passthru(fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE)</operation>
<global-variables/>
<external-variables/>
<variables>
<variable>
<name xmlns="http://marklogic.com/bill/display">x</name>
<prefix/>
<value>fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE</value>
</variable>
<variable>
<name xmlns="http://marklogic.com/bill/display">z</name>
<prefix/>
<value>fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE/TITLE</value>
</variable>
</variables>
</frame>
<frame>
<uri>/display-lib.xqy</uri>
<location><database>0</database><uri>/opt/MarkLogic/bill/display-lib.xqy</uri></location>
<line>195</line>
<column>0</column>
<operation>unorderedList(fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE)</operation>
<global-variables/>
<external-variables/>
<variables>
<variable>
<name xmlns="http://marklogic.com/bill/display">x</name>
<prefix/>
<value>fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE</value>
</variable>
</variables>
</frame>
<frame>
<uri>/display-lib.xqy</uri>
<location><database>0</database><uri>/opt/MarkLogic/bill/display-lib.xqy</uri></location>
<line>45</line>
<column>0</column>
<operation>d:dispatch(fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE)</operation>
<global-variables/>
<external-variables/>
<variables>
<variable>
<name xmlns="http://marklogic.com/bill/display">x</name>
<prefix/>
<value>fn:doc("/shakespeare/plays/dream.xml")/PLAY/PERSONAE</value>
</variable>
</variables>
</frame>
<frame>
<uri>/displayScene.xqy</uri>
<location><database>0</database><uri>/opt/MarkLogic/bill/displayScene.xqy</uri></location>
<line>75</line>
<column>0</column>
<global-variables>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-tab-width</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-default-query-type</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-page-size</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-near</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-debug</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-nbsp</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-elements</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-num</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-color</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-highlight-color</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="">g-highlight-color</name>
<prefix/>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-near-type</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-chars-per-hit</name>
<prefix>s</prefix>
</global-variable>
<global-variable>
<name xmlns="http://marklogic.com/bill/search">g-grey</name>
<prefix>s</prefix>
</global-variable>
</global-variables>
<external-variables/>
<variables>
<variable>
<name xmlns="">fname</name>
<prefix/>
<value>"/shakespeare/plays/dream.xml"</value>
</variable>
<variable>
<name xmlns="">search</name>
<prefix/>
<value>()</value>
</variable>
<variable>
<name xmlns="">type</name>
<prefix/>
<value>"and"</value>
</variable>
<variable>
<name xmlns="">near</name>
<prefix/>
<value>""</value>
</variable>
<variable>
<name xmlns="">near-type</name>
<prefix/>
<value>"and"</value>
</variable>
<variable>
<name xmlns="">act</name>
<prefix/>
<value>0</value>
</variable>
<variable>
<name xmlns="">sceneVariable</name>
<prefix/>
<value>"1"</value>
</variable>
<variable>
<name xmlns="">scene</name>
<prefix/>
<value>1</value>
</variable>
</variables>
</frame>
</stack>
Here is a detailed procedure on how I've tested on my side:
1. I've installed Shakespeare Demo Application on my MarkLogic server
2. I've created an XDBC server with a modules configuration similar to the previously created HTTP Server
3. Inside Oxygen I've created a MarkLogic configuration based on the XDBC server
4. Inside Oxygen's "Data Source Explorer" I've identified the HTTP server and chosen "Enable debug mode" from the contextual menu
5. Inside a browser I access the HTTP server. I notice the server is in debug mode because the browser presents the loading widget for the page.
6. I return to Oxygen, expand the Requests container of the HTTP server. I'm able to see the request I've triggered at the previous step. I select it and from the contextual menu I choose "Debug"

At this point I run the log query I've sent you and I get the log from above. Right now, in the Data Source Explorer, I can explore the modules (for this application, display-lib.xqy), open them and add breakpoints. Can you please follow the same scenario and send me the log file again?

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Mon Jan 16, 2017 11:14 pm
by vkdev
Alex
Our web application is not run on the Http server on Marklogic. Its a separate tomcat server that receives the REST calls.
The mvc spring controller (dispatcher servlet) receives this REST request, calls a service that makes a REST call to xquery extension.
I do see the request in the Marklogic http server when the xquery REST extension module is called. The marklogic xquery files are called and in debug mode, I am able to step into these ML library files, but it does not display the contents of my extension file and does not stop at breakpoints in that file.

Do you have a scenario working similar to this please?
Also, is the bill application also involve custom REST extension files that you are able to debug?

Appreciate your valuable inputs. You have my servers' config. Do you find anything that may be worthy of a change to try out?

Re: Debug Xquery rest-api in MarkLogic

Posted: Tue Jan 17, 2017 11:58 am
by alex_jitianu
Hi,
Our web application is not run on the Http server on Marklogic. Its a separate tomcat server that receives the REST calls.
So, if I understand this correctly, the Tomcat server is the entry point and will delegate at some point to the MarkLogic server.
Also, is the bill application also involve custom REST extension files that you are able to debug?
It is a pure XQuery-based Web application. The MarkLogic HTTP App server is all it needs to run.
I am able to step into these ML library files, but it does not display the contents of my extension file and does not stop at breakpoints in that file.
This "extension file" you mention, is this an XQuery file stored in the MarkLogic server? Or is it a REST extension running on the separate tomcat server?

From the perspective of Oxygen's MarkLogic debugger it doesn't matter how the request is received by the MarkLogic HTTP App Server. But you only have control on the processing done by the MarkLogic server. You can add breakpoints only inside the XQuery files that will be executed during this session.

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Tue Jan 17, 2017 1:07 pm
by vkdev
Yes entry point is tomcat server. and it makes an rest endpoint call that is the Marklogic rest endpoint.

The xquery file is uploaded to ML modules database to /v1/config/resources. We followed the instructions on how to create and install it
https://docs.marklogic.com/guide/rest-d ... s#id_59112.

As I mentioned in my first post,
When I look at the datasource explorer, I see the xquery files under the structure- modules/marklogic.rest.resource/tasklist/assets/resource.xqy

What am I missing? Is it some configuration?

Re: Debug Xquery rest-api in MarkLogic

Posted: Tue Jan 17, 2017 6:05 pm
by alex_jitianu
Hi,

What I didn't have in my tests was an XQuery Resource Service Extension. I'll create such a XQuery Resource Service Extension myself and let you know what I discover.

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Wed Jan 18, 2017 5:15 pm
by alex_jitianu
Hi,

Debugging a REST resource extension appears 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 will 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:

oxygen://{HOST.NAME}/{DATA.SOURCE}${CONNECTION.NAME}/fs//$/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xqy$/MarkLogic/rest-api/lib/extensions-util.xqy

{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. 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.

I'll report this issue to MarkLogic and I will keep you posted with what they say. Please let me know if you succeed in debugging the extension using the above procedure.

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Thu Jan 19, 2017 1:11 pm
by vkdev
Alex-

you wrote-
"Unfortunately, another limitation that I discovered is that you can't add breakpoints inside your extension. This means that you will have to rely on Step In/Out/Over actions to navigate the query."

If i cannot put break points inside my extension, then how can i debug?

Re: Debug Xquery rest-api in MarkLogic

Posted: Thu Jan 19, 2017 3:56 pm
by alex_jitianu
Hi,

Once you are in the extension you can use Step In, Step Out, Step Over to navigate. Step In gives you fine control and Step Over, Step Out can help you jump over large sections that you are not interested in. I know that having breakpoints make it easier to get to the area you are interested in but until the people from MarkLogic fix the dbg:line() function I don't see any other way.
Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Thu Jan 19, 2017 5:27 pm
by vkdev
I get an error when I try to open url-
oxygen://im4w193.svr.us.jpmchase.net/MarkLogic$bpmn-poc/fs//$/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xqy$/MarkLogic/rest-api/lib/extensions-util.xqy

Datasource name is MarkLogic and connection name is bpmn-poc


java.io.IOException: Cannot open the specified file: SVC-FILOPN: xdmp:document-get("/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xq...") -- File open error: open '/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xqy': No such file or directory
at ro.sync.db.nxd.marklogic.MarkLogicXCCSession.getInputStream(Unknown Source)
at ro.sync.db.nxd.NXDURLConnection.getInputStream(Unknown Source)
at ro.sync.exml.editor.xb.d(Unknown Source)
at ro.sync.exml.editor.ge.v(Unknown Source)
at ro.sync.exml.editor.ge.db(Unknown Source)
at ro.sync.exml.editor.tc.open(Unknown Source)
at ro.sync.exml.editor.vd.pbl(Unknown Source)
at ro.sync.exml.editor.vd.open(Unknown Source)
at ro.sync.exml.e.u.c(Unknown Source)
at ro.sync.exml.e.u.d(Unknown Source)
at ro.sync.exml.e.u.e(Unknown Source)
at ro.sync.exml.e.d.wxh(Unknown Source)
at ro.sync.exml.e.d$2.actionPerformed(Unknown Source)
at ro.sync.ui.application.action.w$_b$1.the(Unknown Source)
at ro.sync.ui.application.nb.run(Unknown Source)
Caused by: javax.xml.transform.TransformerException: SVC-FILOPN: xdmp:document-get("/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xq...") -- File open error: open '/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xqy': No such file or directory
at ro.sync.db.nxd.marklogic.MarkLogicXCCSession.vp(Unknown Source)
at ro.sync.db.nxd.marklogic.MarkLogicXCCSession.evaluateXQuery(Unknown Source)
... 15 more

Re: Debug Xquery rest-api in MarkLogic

Posted: Fri Jan 20, 2017 9:57 am
by alex_jitianu
Hi,

Let's try adding a breakpoint in the Breakpoints view using that URL. In the XQuery Debugger view, in the Breakpoints view invoke the contextual menu and select Add:
1. As the URL set:

Code: Select all

oxygen://im4w193.svr.us.jpmchase.net/MarkLogic$bpmn-poc/fs//$/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xqy$/MarkLogic/rest-api/lib/extensions-util.xqy
2. And as the Line put 820
3. Click O.K. Disable or remove all other breakpoints.

Start the debugging now and let us see how it goes.

Best regards,
Alex

Re: Debug Xquery rest-api in MarkLogic

Posted: Fri Jan 20, 2017 5:32 pm
by vkdev
I have added the url in the breakpoint view. How do I start the debugger now?

I just tried right click on the breakpoint resource(url) and select run to breakpoint- it says no XSL selected.

When I select go to- I get the same error- Cannot open the specified file-

SVC-FILOPN: xdmp:document-get("/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xq...") -- File open error: open '/opt/MarkLogic/Modules/MarkLogic/rest-api/lib/extensions-util.xqy': No such file or directory

Re: Debug Xquery rest-api in MarkLogic

Posted: Fri Jan 20, 2017 5:38 pm
by alex_jitianu
Hi,

After you add the breakpoint you start the debugger like you did before:
1. Inside Oxygen's "Data Source Explorer" I've identified the HTTP server and chosen "Enable debug mode" from the contextual menu
2. Inside a browser I access the HTTP server. I notice the server is in debug mode because the browser presents the loading widget for the page.
3. I return to Oxygen, expand the Requests container of the HTTP server. I'm able to see the request I've triggered at the previous step. I select it and from the contextual menu I choose "Debug"

After this, click Run and it should top at the breakpoint.

Re: Debug Xquery rest-api in MarkLogic

Posted: Mon Jan 23, 2017 7:43 pm
by vkdev
Alex
When I followed the steps to debug at line 820 on extensions-util.xqy
I get this-

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: waas-audit-xdbc-server, Modules database: WaaS_Audit_Server-modules, Modules root: /. DBG-MODULEDNE: ns1:line(17917678279175982016, "/MarkLogic/rest-api/lib/extensions-util.xqy", xs:unsignedInt("820")) -- Module not found: /MarkLogic/rest-api/lib/extensions-util.xqy

Re: Debug Xquery rest-api in MarkLogic

Posted: Wed Jan 25, 2017 11:55 am
by alex_jitianu
Hi,

This is quite unexpected... I'm testing on MarkLogic 8.0-6.1. You said you were using 8.1. Is that an early access? Let's try it like this:

1. Disable the breakpoint.
2. Inside Oxygen's "Data Source Explorer" identify the HTTP server and choose "Enable debug mode" from the contextual menu
3. Inside a browser access the HTTP server.
4. Return to Oxygen, expand the Requests container of the HTTP server. Notice the request triggered at the previous step. Select it and from the contextual menu choose "Debug"
5. Keep using Step In, Step Over and Step Out. You will eventually end up at the location where the Rest extension is invoked. On a 8.0-6.1 server, that location was extensions-util.xqy in a function called extut:call-service(). In your case it might be a different module. Once you reach that point you can add a breakpoint there. The next time you debug, because you now have a valid breakpoint, you will be able to simply use "Run" to jump to that location.



Best regards,
Alex