Quantcast

eXist3.0: doc() via XSLTServlet throws URIResolver for perfectly fine URIs

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

eXist3.0: doc() via XSLTServlet throws URIResolver for perfectly fine URIs

ron.vandenbranden
Hi,

When switching an app from eXist-3.0RC1 to the stable eXist-3.0, I'm
hitting a HTTP Status 500 error, stating a"SAX exception while
transforming node: Exception thrown by URIResolver". This is caused by a
call to the doc() function inside an XSLT stylesheet that is called via
XSLTServlet in the controller. The logs don't contain any sensible
pointers, but I've been able to nail the issue to a problem with
resolving URI's in XSLT stylesheets.

Some details, first:
      -eXist-3.0 (running standalone, with its own embedded Jetty server)
      -Oracle Java 8
      -error occurs on both Linux + Windows

Unfortunately, the problem was evasive enough so that I haven't been
able to reproduce it exactly: it happens from eXist-3.0RC2 onwards, and
is definitely restricted to a specific context:
      -only when an app is stored and executed in the database (file
system works fine)
      -when the doc() function is called in an XSLT stylesheet that is
invoked via XSLTServlet (running the same stylesheet via
transform:transform() works fine)

It has taken me all night, but I've been able to cook up a test app that
illustrates similar behaviour (my specific problem is with paths to
local files, which I couldn't reproduce, but eXist-3.0 there seems to
have a problem with absolute paths as well).

Basically, when an XSLT stylesheet like this:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all" version="2.0">
      <xsl:variable name="doc" select="doc('http://localhost:8080/exist/apps/doc-test/test.xml')"/>
      <xsl:template match="/">
        <xslt-output>
          <xsl:copy-of select="$doc"/>
        </xslt-output>
      </xsl:template>
    </xsl:stylesheet>

...is invoked via XSLTServlet, a "SAX exception while transforming node:
Exception thrown by URIResolver" error is thrown, even when the document
requested via doc() is perfectly accessible via
http://localhost:8080/exist/apps/doc-test/test.xml.

Moreover, executing the *same* XSLT stylesheet via the
transform:transform() function just works:

    xquery version "3.0";
    let $xml := doc('/db/apps/doc-test/test.xml')
    let $xsl := doc('/db/apps/doc-test/test.xsl')
    return transform:transform($xml, $xsl, ())

What's more, this order seems to matter: after the transform:transform()
function has processed the XSLT stylesheet successfully, a subsequent
execution via XSLTServlet now works fine as well (but only if the error
has been hit before)!

I've tried to wrap this up in a sample webapp (see attachment) that
illustrates the behaviour. Do note the difference between the execution
context: if the webapp runs from the file system, there's no problem at
all. If the .xar file is deployed in the database, the scenario sketched
out above is happening. This test app works normally in RC1 and RC2
(even though it probably has URIResolver problems, too that I wasn't
able to reproduce), but fails in the final eXist-3.0. I wonder if this
is somehow related to the issues that have been addressed recently in
https://github.com/wolfgangmm/exist/commit/f4d3ae88a0d8610f45ddbfd06976c75370c1c193?
I wouldn't mind filing a bug report, if only it were easier to pinpoint
the issue.

Unfortunately, this is quite critical for me at this moment, so I'm
trying to revive my eXist-3.0RC1 and build a war file (for deployment in
Tomcat). So far, my build attempts failed with

    Error: Could not find or load main class
org.apache.tools.ant.launch.Launcher

I hope to find an immediate workaround, otherwise I'll have to downgrade
to eXist-2.2 again :-/.

Best,

Ron


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open

doc-test-0.1.xar (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: eXist3.0: doc() via XSLTServlet throws URIResolver for perfectly fine URIs

ron.vandenbranden
Ok, I've tried to describe and summarize the issue in
https://github.com/eXist-db/exist/issues/1312. Hope this helps!

Ron


On 2/03/2017 14:07, Ron Van den Branden wrote:

> Hi,
>
> When switching an app from eXist-3.0RC1 to the stable eXist-3.0, I'm
> hitting a HTTP Status 500 error, stating a"SAX exception while
> transforming node: Exception thrown by URIResolver". This is caused by
> a call to the doc() function inside an XSLT stylesheet that is called
> via XSLTServlet in the controller. The logs don't contain any sensible
> pointers, but I've been able to nail the issue to a problem with
> resolving URI's in XSLT stylesheets.
>
> Some details, first:
>      -eXist-3.0 (running standalone, with its own embedded Jetty server)
>      -Oracle Java 8
>      -error occurs on both Linux + Windows
>
> Unfortunately, the problem was evasive enough so that I haven't been
> able to reproduce it exactly: it happens from eXist-3.0RC2 onwards,
> and is definitely restricted to a specific context:
>      -only when an app is stored and executed in the database (file
> system works fine)
>      -when the doc() function is called in an XSLT stylesheet that is
> invoked via XSLTServlet (running the same stylesheet via
> transform:transform() works fine)
>
> It has taken me all night, but I've been able to cook up a test app
> that illustrates similar behaviour (my specific problem is with paths
> to local files, which I couldn't reproduce, but eXist-3.0 there seems
> to have a problem with absolute paths as well).
>
> Basically, when an XSLT stylesheet like this:
>
>    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> exclude-result-prefixes="#all" version="2.0">
>      <xsl:variable name="doc"
> select="doc('http://localhost:8080/exist/apps/doc-test/test.xml')"/>
>      <xsl:template match="/">
>        <xslt-output>
>          <xsl:copy-of select="$doc"/>
>        </xslt-output>
>      </xsl:template>
>    </xsl:stylesheet>
>
> ...is invoked via XSLTServlet, a "SAX exception while transforming
> node: Exception thrown by URIResolver" error is thrown, even when the
> document requested via doc() is perfectly accessible via
> http://localhost:8080/exist/apps/doc-test/test.xml.
>
> Moreover, executing the *same* XSLT stylesheet via the
> transform:transform() function just works:
>
>    xquery version "3.0";
>    let $xml := doc('/db/apps/doc-test/test.xml')
>    let $xsl := doc('/db/apps/doc-test/test.xsl')
>    return transform:transform($xml, $xsl, ())
>
> What's more, this order seems to matter: after the
> transform:transform() function has processed the XSLT stylesheet
> successfully, a subsequent execution via XSLTServlet now works fine as
> well (but only if the error has been hit before)!
>
> I've tried to wrap this up in a sample webapp (see attachment) that
> illustrates the behaviour. Do note the difference between the
> execution context: if the webapp runs from the file system, there's no
> problem at all. If the .xar file is deployed in the database, the
> scenario sketched out above is happening. This test app works normally
> in RC1 and RC2 (even though it probably has URIResolver problems, too
> that I wasn't able to reproduce), but fails in the final eXist-3.0. I
> wonder if this is somehow related to the issues that have been
> addressed recently in
> https://github.com/wolfgangmm/exist/commit/f4d3ae88a0d8610f45ddbfd06976c75370c1c193?
> I wouldn't mind filing a bug report, if only it were easier to
> pinpoint the issue.
>
> Unfortunately, this is quite critical for me at this moment, so I'm
> trying to revive my eXist-3.0RC1 and build a war file (for deployment
> in Tomcat). So far, my build attempts failed with
>
>    Error: Could not find or load main class
> org.apache.tools.ant.launch.Launcher
>
> I hope to find an immediate workaround, otherwise I'll have to
> downgrade to eXist-2.2 again :-/.
>
> Best,
>
> Ron
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: eXist3.0: doc() via XSLTServlet throws URIResolver for perfectly fine URIs

Martin Holmes
Hi Ron,

Could this be due to a change in the version of Saxon about a year ago?
Saxon has been getting increasingly rigorous in its behaviour.

Cheers,
Martin

On 2017-03-02 09:19 AM, Ron Van den Branden wrote:

> Ok, I've tried to describe and summarize the issue in
> https://github.com/eXist-db/exist/issues/1312. Hope this helps!
>
> Ron
>
>
> On 2/03/2017 14:07, Ron Van den Branden wrote:
>> Hi,
>>
>> When switching an app from eXist-3.0RC1 to the stable eXist-3.0, I'm
>> hitting a HTTP Status 500 error, stating a"SAX exception while
>> transforming node: Exception thrown by URIResolver". This is caused by
>> a call to the doc() function inside an XSLT stylesheet that is called
>> via XSLTServlet in the controller. The logs don't contain any sensible
>> pointers, but I've been able to nail the issue to a problem with
>> resolving URI's in XSLT stylesheets.
>>
>> Some details, first:
>>      -eXist-3.0 (running standalone, with its own embedded Jetty server)
>>      -Oracle Java 8
>>      -error occurs on both Linux + Windows
>>
>> Unfortunately, the problem was evasive enough so that I haven't been
>> able to reproduce it exactly: it happens from eXist-3.0RC2 onwards,
>> and is definitely restricted to a specific context:
>>      -only when an app is stored and executed in the database (file
>> system works fine)
>>      -when the doc() function is called in an XSLT stylesheet that is
>> invoked via XSLTServlet (running the same stylesheet via
>> transform:transform() works fine)
>>
>> It has taken me all night, but I've been able to cook up a test app
>> that illustrates similar behaviour (my specific problem is with paths
>> to local files, which I couldn't reproduce, but eXist-3.0 there seems
>> to have a problem with absolute paths as well).
>>
>> Basically, when an XSLT stylesheet like this:
>>
>>    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> exclude-result-prefixes="#all" version="2.0">
>>      <xsl:variable name="doc"
>> select="doc('http://localhost:8080/exist/apps/doc-test/test.xml')"/>
>>      <xsl:template match="/">
>>        <xslt-output>
>>          <xsl:copy-of select="$doc"/>
>>        </xslt-output>
>>      </xsl:template>
>>    </xsl:stylesheet>
>>
>> ...is invoked via XSLTServlet, a "SAX exception while transforming
>> node: Exception thrown by URIResolver" error is thrown, even when the
>> document requested via doc() is perfectly accessible via
>> http://localhost:8080/exist/apps/doc-test/test.xml.
>>
>> Moreover, executing the *same* XSLT stylesheet via the
>> transform:transform() function just works:
>>
>>    xquery version "3.0";
>>    let $xml := doc('/db/apps/doc-test/test.xml')
>>    let $xsl := doc('/db/apps/doc-test/test.xsl')
>>    return transform:transform($xml, $xsl, ())
>>
>> What's more, this order seems to matter: after the
>> transform:transform() function has processed the XSLT stylesheet
>> successfully, a subsequent execution via XSLTServlet now works fine as
>> well (but only if the error has been hit before)!
>>
>> I've tried to wrap this up in a sample webapp (see attachment) that
>> illustrates the behaviour. Do note the difference between the
>> execution context: if the webapp runs from the file system, there's no
>> problem at all. If the .xar file is deployed in the database, the
>> scenario sketched out above is happening. This test app works normally
>> in RC1 and RC2 (even though it probably has URIResolver problems, too
>> that I wasn't able to reproduce), but fails in the final eXist-3.0. I
>> wonder if this is somehow related to the issues that have been
>> addressed recently in
>> https://github.com/wolfgangmm/exist/commit/f4d3ae88a0d8610f45ddbfd06976c75370c1c193?
>> I wouldn't mind filing a bug report, if only it were easier to
>> pinpoint the issue.
>>
>> Unfortunately, this is quite critical for me at this moment, so I'm
>> trying to revive my eXist-3.0RC1 and build a war file (for deployment
>> in Tomcat). So far, my build attempts failed with
>>
>>    Error: Could not find or load main class
>> org.apache.tools.ant.launch.Launcher
>>
>> I hope to find an immediate workaround, otherwise I'll have to
>> downgrade to eXist-2.2 again :-/.
>>
>> Best,
>>
>> Ron
>>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: eXist3.0: doc() via XSLTServlet throws URIResolver for perfectly fine URIs

ron.vandenbranden
In reply to this post by ron.vandenbranden
Hi Martin,

Thanks for your suggestion. I don't think that can be the issue, since
the transformation runs fine when the app is stored on the file system
(hence with the same eXist + Saxon installation). Only when the app is
deployed in the database, and only when the XSLT tranformation is
initated with XSLTServlet, the URIResolver error is thrown (execution
via transform:transform() runs without errors). It seems Dmitriy has
been digging into the issue; I'm eagerly awaiting to test his PR
(https://github.com/eXist-db/exist/pull/1316) once it'll have been merged!

Best,

Ron

On 2/03/2017 13:16, Martin Holmes wrote:

> On 2/03/2017 13:16, Martin Holmes wrote:
>
> Hi Ron,
>
> Could this be due to a change in the version of Saxon about a year ago?
> Saxon has been getting increasingly rigorous in its behaviour.
>
> Cheers,
> Martin
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: eXist3.0: doc() via XSLTServlet throws URIResolver for perfectly fine URIs

RemiKoutcherawy
In reply to this post by ron.vandenbranden
Le 02/03/2017 à 18:19, Ron Van den Branden a écrit :
> Ok, I've tried to describe and summarize the issue in
> https://github.com/eXist-db/exist/issues/1312. Hope this helps!
>
> Ron
>
Hi List,

I have the same problem, and tried the patch
https://github.com/eXist-db/exist/pull/1316
which sadly corrects only part of the bug.

Here is an example : A-Bug.xql
It creates "A-Lut.xml" in the base then call doc() inside XSL to read
"A_Lut.xml"

With
eXist-db version: 3.0 / acd0c14
Java: 1.8.0_112
Operating system: macOS 10.12.3 (16D32)

It fails on <xsl:value-of select="$lutdoc"/>
exerr:ERROR Exception while transforming node: I/O error reported by XML
parser processing file:/Users/remi/git/exist-develop/A-Lut.xml:
/Users/remi/git/exist-develop/A-Lut.xml (No such file or directory) [at
line 37, column 16]
( maybe a security issue, 3.0 reads the filesystem instead of the base )

With patch, in eXide, it finds the file "A-Lut.xml" in the base and reports:
<ok> Lutdoc:First100Second200</ok>

But uncomment <xsl:value-of select="$lutdoc//product/id"/> and it fails :
exerr:ERROR Exception while transforming node: Internal error evaluating
template in module [at line 36, column 16]

To be complete, uncomment the next line, tweak xsl param, and it reports
correctly :
<ok> Lutdoc: First 100 Second 200 LutIds:100 200 Name:First</ok>

//--- A-Bug.xql in /db/apps/bugs
xquery version "3.0";
declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
declare option exist:serialize "method=xml media-type=text/html";

let $lut :=
<lut>
   <product>
     <name>First</name>
     <id>100</id>
   </product>
   <product>
     <name>Second</name>
     <id>200</id>
   </product>
</lut>

let $store := xmldb:store('/db/apps/bugs', 'A-Lut.xml', $lut)

let $xmlin :=
<root>
   <product>
     <id>100</id>
   </product>
</root>

let $xslSheet :=
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
     <xsl:param name="lut">A-Lut.xml</xsl:param>
     <xsl:template match="id">
       <xsl:variable name="lutdoc" select="doc($lut)"/>
       Lutdoc:<xsl:value-of select="$lutdoc"/>
<!--      LutIds:<xsl:value-of select="$lutdoc//product/id"/>-->
<!--      Name:<xsl:value-of select="$lutdoc//product/id[. =
current()]/../name"/>-->
     </xsl:template>
   </xsl:stylesheet>

let $xmlout := transform:transform($xmlin, $xslSheet, ())
return <ok>{$xmlout}</ok>
//---

For the sake of completeness by "tweak xsl param" I mean
replace xsl:param name="lut">A-Lut.xml</xsl:param>
with <xsl:param name="lut">xmldb:exist:///db/apps/bugs/A-Lut.xml</xsl:param>

Rémi


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: eXist3.0: doc() via XSLTServlet throws URIResolver for perfectly fine URIs

Dmitriy Shabanov
Hi Rémi,

On Sun, Mar 5, 2017 at 5:45 PM, Rémi Koutchérawy <[hidden email]> wrote:
Le 02/03/2017 à 18:19, Ron Van den Branden a écrit :
> Ok, I've tried to describe and summarize the issue in
> https://github.com/eXist-db/exist/issues/1312. Hope this helps!
>
> Ron
>
Hi List,

I have the same problem, and tried the patch
https://github.com/eXist-db/exist/pull/1316
which sadly corrects only part of the bug.

Here is an example : A-Bug.xql
It creates "A-Lut.xml" in the base then call doc() inside XSL to read
"A_Lut.xml"

With
eXist-db version: 3.0 / acd0c14
Java: 1.8.0_112
Operating system: macOS 10.12.3 (16D32)

It fails on <xsl:value-of select="$lutdoc"/>
exerr:ERROR Exception while transforming node: I/O error reported by XML
parser processing file:/Users/remi/git/exist-develop/A-Lut.xml:
/Users/remi/git/exist-develop/A-Lut.xml (No such file or directory) [at
line 37, column 16]
( maybe a security issue, 3.0 reads the filesystem instead of the base )

With patch, in eXide, it finds the file "A-Lut.xml" in the base and reports:
<ok> Lutdoc:First100Second200</ok>

But uncomment <xsl:value-of select="$lutdoc//product/id"/> and it fails :
exerr:ERROR Exception while transforming node: Internal error evaluating
template in module [at line 36, column 16]

To be complete, uncomment the next line, tweak xsl param, and it reports
correctly :
<ok> Lutdoc: First 100 Second 200 LutIds:100 200 Name:First</ok>

//--- A-Bug.xql in /db/apps/bugs
xquery version "3.0";
declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
declare option exist:serialize "method=xml media-type=text/html";

let $lut :=
<lut>
   <product>
     <name>First</name>
     <id>100</id>
   </product>
   <product>
     <name>Second</name>
     <id>200</id>
   </product>
</lut>

let $store := xmldb:store('/db/apps/bugs', 'A-Lut.xml', $lut)

let $xmlin :=
<root>
   <product>
     <id>100</id>
   </product>
</root>

let $xslSheet :=
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
     <xsl:param name="lut">A-Lut.xml</xsl:param>
     <xsl:template match="id">
       <xsl:variable name="lutdoc" select="doc($lut)"/>
       Lutdoc:<xsl:value-of select="$lutdoc"/>
<!--      LutIds:<xsl:value-of select="$lutdoc//product/id"/>-->
<!--      Name:<xsl:value-of select="$lutdoc//product/id[. =
current()]/../name"/>-->
     </xsl:template>
   </xsl:stylesheet>

let $xmlout := transform:transform($xmlin, $xslSheet, ())
return <ok>{$xmlout}</ok>
//---

For the sake of completeness by "tweak xsl param" I mean
replace xsl:param name="lut">A-Lut.xml</xsl:param>
with <xsl:param name="lut">xmldb:exist:///db/apps/bugs/A-Lut.xml</xsl:param>

Can you one next issue with that description? Btw, did you try to run it on saxon?

--
Dmitriy Shabanov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...