marklogic-community / roxy

Deployment tool for MarkLogic applications. Also provides optional unit test and XQuery MVC structure
Other
87 stars 66 forks source link

ML 9.0-3.1 fails with XDMP-IMPMODNS when using /roxy/lib/rewriter-lib.xqy #865

Open rhdunn opened 6 years ago

rhdunn commented 6 years ago

Trying to use /roxy/lib/rewriter-lib.xqy with MarkLogic 9.0-3.1 results in the following error:

Notice: XDMP-IMPMODNS: (err:XQST0059) Import module namespace http://marklogic.com/rest-api/endpoints/config does not match target namespace http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED of imported module /MarkLogic/rest-api/endpoints/config.xqy
Notice:+in /roxy/lib/rewriter-lib.xqy, at 5:0 [1.0-ml]

This is because /MarkLogic/rest-api/endpoints/config.xqy has changed the module namespace to:

module namespace conf = "http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED";
gpsbabu commented 6 years ago

We have also encountered the above issue whilst we are upgrading ML 8 to latest ML 9.0-3.1 (in Windows using MarkLogic-9.0-3.1-amd64.msi) and encountered an error while using with roxy rest-api.

Error:

<error:error xsi:schemalocation="http://marklogic.com/xdmp/e... error.xsd" xmlns:error="http://marklogic.com/xdmp/e..." xmlns:xsi="http://www.w3.org/2001/XMLS...">
<error:code>XDMP-IMPMODNS</error:code>
<error:name>err:XQST0059</error:name>
<error:xquery-version>1.0-ml</error:xquery-version>
<error:message>Import module namespace mismatch</error:message>
<error:format-string>XDMP-IMPMODNS: (err:XQST0059) Import module namespace http://marklogic.com/rest-a... does not match target namespace http://marklogic.com/rest-a... of imported module /MarkLogic/rest-api/endpoints/config.xqy</error:format-string>
<error:retryable>false</error:retryable>
<error:expr/>
<error:data>
<error:datum>http://marklogic.com/rest-a...
<error:datum>http://marklogic.com/rest-a...
<error:datum>/MarkLogic/rest-api/endpoints/config.xqy</error:datum>
</error:data>
<error:stack>
<error:frame>
<error:uri>/roxy/lib/rewriter-lib.xqy</error:uri>
<error:line>5</error:line>
<error:column>0</error:column>
<error:xquery-version>1.0-ml</error:xquery-version>
</error:frame>
</error:stack>
</error:error>

Problematic File: C:\Program Files\MarkLogic\Modules\MarkLogic\rest-api\endpoints\config.xqy

xquery version "1.0-ml";

(: Copyright 2011-2017 MarkLogic Corporation. All Rights Reserved. :)

module namespace conf = "http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED";

Resolution (required): The namespace declared in config.xqy has a suffix "_DELETE_IF_UNUSED", which looks wrong and when I removed the text "_DELETE_IF_UNUSED" in config.xqy, all worked fine.

Hope this will be fixed.

grtjn commented 6 years ago

MarkLogic rest-api has moved over to using the declarative xml rewriter, and as such config.xqy and anything else related to the old xqy rewriter has become obsolete. That has been such since ML8, but they now moved forward with actually removing internal code not used by MarkLogic Server itself.

rhdunn commented 6 years ago

Searching the roxy rewriter-lib.xqy file, I cannot see where the conf import is used. Therefore, removing that import should fix the problem.

rhdunn commented 6 years ago

Ah, I see now -- the code is using xdmp:functions() to select functions from the imported conf module, by looking at the in-scope functions. As such, there are two possible fixes for roxy:

  1. create a function to return those functions from a given module namespace and path, trying the ML 9.0-3.1 version, then the earlier version;
  2. import the relevant missing config functions into roxy.

Option 1 will work for now, but would break again when that file is removed. Option 2 is like the previous fix for issue #416, and would require authorization from MarkLogic to do this.

Also note that the Roxy rewriter-lib.xqy file is missing a copyright and apache license header notice comment.

rhdunn commented 5 years ago

Is there a reason these config functions are checked for? They appear to be all defining MarkLogic endpoint paths (e.g. ^/(v1|LATEST)/documents/?$), and removing the import does not appear to break the rewriter-lib.xqy functionality.

grtjn commented 5 years ago

It is for hybrid roxy apps...

rhdunn commented 5 years ago

I have an application that makes use of the roxy rewriter.xqy and rewriter-lib.xqy. With MarkLogic 9.0 it is generating the XDMP-IMPMODNS error in the original report. This error is referring to the following import in rewriter-lib.xqy:

import module namespace conf = "http://marklogic.com/rest-api/endpoints/config"
  at "/MarkLogic/rest-api/endpoints/config.xqy";

This import is used in rewriter:rewrite-rules on line 36 to add the config functions to $rules on line 27. Looking at those functions, they are defining URIs for the MarkLogic REST APIs (that have been replaced by the rewriter.xml files). These include things like:

^/(v1|LATEST)/search(/)?$
^/(v1|LATEST)/documents/?$

These don't appear relevant for hybrid rox apps.

Specifically, removing the import does not break anything in that application.

grtjn commented 5 years ago

Roxy supports 4 app types:

The last started to break when engineering launched the declarative rewriter.

Hybrid allows you to use mvc as well as rest calls. If you dont use rest calls, you can safely delete those lines you said.

I think roxy was lazily giving people the hybrid rewriter for both hybrid and mvc..

rhdunn commented 5 years ago

Thanks for the clarification.

rskainth82 commented 5 years ago

We are removing the following statement from rewriter-lib.xqy Roxy library module as this statement required a change to the namespace from http://marklogic.com/rest-api/endpoints/config to http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED when we are moving from ML8 to ML9.

Can you please confirm that there won’t be any issues in doing so? This would allow us to avoid any downtime, that we would need otherwise, if we need to retain this import for any reason.

This import is used nowhere in rewriter-lib.xqy module of Roxy modules.

import module namespace conf = "http://marklogic.com/rest-api/endpoints/config" at "/MarkLogic/rest-api/endpoints/config.xqy";

The above import statement will change to the following statement, if we need to retain this for some reason when we go to ML9 and that incurs a down time. import module namespace conf = "http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED" at "/MarkLogic/rest-api/endpoints/config.xqy";

Thanks, Rupinder