Runtime exception in xquery with new snapshot

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

Runtime exception in xquery with new snapshot

Chris Marasti-Georg
Occurs near the mixture of constructed <something> and $doc.  With only one or the other, I get no exception.  First the xml, then the xquery, then the stacktrace.   I've also attached the xml and xql
 
XML:
<template>
    <something/>
</template>
 
<something-big>
{
let $doc := /template
return (
 <something>{$doc/something}</something>,
 $doc
)
}
</something-big>
 
Stacktrace:
org.xmldb.api.base.XMLDBException: java.lang.RuntimeException: cannot compare NodeProxy with org.exist.memtree.ElementImpl
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:64)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:36)
 at org.exist.xmldb.RemoteXPathQueryService.execute(RemoteXPathQueryService.java:212)
 at org.exist.client.QueryDialog$QueryThread.run(QueryDialog.java:397)
Caused by: org.apache.xmlrpc.XmlRpcException: java.lang.RuntimeException: cannot compare NodeProxy with org.exist.memtree.ElementImpl
 at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:457)
 at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:163)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:53)
 ... 3 more
Caused by: org.apache.xmlrpc.XmlRpcException: java.lang.RuntimeException: cannot compare NodeProxy with org.exist.memtree.ElementImpl
 at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:457)
 at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:163)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:53)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:36)
 at org.exist.xmldb.RemoteXPathQueryService.execute(RemoteXPathQueryService.java:212)
 at org.exist.client.QueryDialog$QueryThread.run(QueryDialog.java:397)

temp.xml (58 bytes) Download Attachment
temp.xql (174 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: Runtime exception in xquery with new snapshot

Chris Marasti-Georg
More:  The stacktrace posted was from the client - not as useful.  Here's the important stuff, from the web end of things:
 
java.lang.RuntimeException: cannot compare NodeProxy with org.exist.memtree.ElementImpl
org.exist.dom.NodeProxy.compareTo(Unknown Source)
java.util.TreeMap.compare(Unknown Source)
java.util.TreeMap.getEntry(Unknown Source)
java.util.TreeMap.containsKey(Unknown Source)
java.util.TreeSet.contains(Unknown Source)
org.exist.xquery.value.ValueSequence.removeDuplicates(Unknown Source)


From: [hidden email] [mailto:[hidden email]] On Behalf Of Chris Marasti-Georg
Sent: Wednesday, October 26, 2005 10:19 AM
To: [hidden email]
Subject: [Exist-open] Runtime exception in xquery with new snapshot

Occurs near the mixture of constructed <something> and $doc.  With only one or the other, I get no exception.  First the xml, then the xquery, then the stacktrace.   I've also attached the xml and xql
 
XML:
<template>
    <something/>
</template>
 
<something-big>
{
let $doc := /template
return (
 <something>{$doc/something}</something>,
 $doc
)
}
</something-big>
 
Stacktrace:
org.xmldb.api.base.XMLDBException: java.lang.RuntimeException: cannot compare NodeProxy with org.exist.memtree.ElementImpl
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:64)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:36)
 at org.exist.xmldb.RemoteXPathQueryService.execute(RemoteXPathQueryService.java:212)
 at org.exist.client.QueryDialog$QueryThread.run(QueryDialog.java:397)
Caused by: org.apache.xmlrpc.XmlRpcException: java.lang.RuntimeException: cannot compare NodeProxy with org.exist.memtree.ElementImpl
 at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:457)
 at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:163)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:53)
 ... 3 more
Caused by: org.apache.xmlrpc.XmlRpcException: java.lang.RuntimeException: cannot compare NodeProxy with org.exist.memtree.ElementImpl
 at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:457)
 at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:163)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:53)
 at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:36)
 at org.exist.xmldb.RemoteXPathQueryService.execute(RemoteXPathQueryService.java:212)
 at org.exist.client.QueryDialog$QueryThread.run(QueryDialog.java:397)
Reply | Threaded
Open this post in threaded view
|

Re: Runtime exception in xquery with new snapshot

Wolfgang Meier-2
In reply to this post by Chris Marasti-Georg
> org.xmldb.api.base.XMLDBException: java.lang.RuntimeException: cannot
> compare NodeProxy with org.exist.memtree.ElementImpl

Sorry for that. I changed NodeProxy.compareTo some time ago because I
thought it should be forbidden to compare NodeProxy to anything else
than a NodeProxy. I have been mistaken: it is possible to mix different
node implementation types in the same sequence. NodeProxy.compareTo
should thus be changed back to its old implementation, i.e.:

public int compareTo(Object other) {
   if(!(other instanceof NodeProxy))
     return 1;
   return compareTo((NodeProxy) other);
}

I attach a patch.

Wolfgang

Index: NodeProxy.java
===================================================================
RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/NodeProxy.java,v
retrieving revision 1.64
diff -u -r1.64 NodeProxy.java
--- NodeProxy.java 30 Sep 2005 21:30:21 -0000 1.64
+++ NodeProxy.java 26 Oct 2005 15:22:09 -0000
@@ -27,6 +27,7 @@
 import org.exist.storage.RangeIndexSpec;
 import org.exist.storage.StorageAddress;
 import org.exist.storage.serializers.Serializer;
+import org.exist.util.sanity.SanityCheck;
 import org.exist.xquery.Cardinality;
 import org.exist.xquery.XPathException;
 import org.exist.xquery.value.AtomicValue;
@@ -184,7 +185,7 @@
 
  public int compareTo(Object other) {
  if(!(other instanceof NodeProxy))
- throw new RuntimeException("cannot compare NodeProxy with " + other.getClass().getName());
+ return 1;
  return compareTo((NodeProxy) other);
  }
 
@@ -1051,6 +1052,7 @@
         if (nodeType != UNKNOWN_NODE_TYPE && nodeType != Node.ELEMENT_NODE)
             return NodeSet.EMPTY_SET;
         NodeImpl node = (NodeImpl) getNode();
+        SanityCheck.ASSERT(node == null, "Node with gid " + gid + " not found!");
         if (node.getNodeType() != Node.ELEMENT_NODE)
             return NodeSet.EMPTY_SET;
         AttrImpl attr = (AttrImpl)
Reply | Threaded
Open this post in threaded view
|

Re: Runtime exception in xquery with new snapshot

Ulrike Schmidt
Wolfgang Meier wrote:

>> org.xmldb.api.base.XMLDBException: java.lang.RuntimeException: cannot
>> compare NodeProxy with org.exist.memtree.ElementImpl
>
>
> Sorry for that. I changed NodeProxy.compareTo some time ago because I
> thought it should be forbidden to compare NodeProxy to anything else
> than a NodeProxy. I have been mistaken: it is possible to mix
> different node implementation types in the same sequence.
> NodeProxy.compareTo should thus be changed back to its old
> implementation, i.e.:
>
> public int compareTo(Object other) {
>   if(!(other instanceof NodeProxy))
>     return 1;
>   return compareTo((NodeProxy) other);
> }
>
> I attach a patch.

I just tried to apply this patch to the snapshot, but I am having a few
problems (it is the first time that I ever tried to apply a patch).

First all hunks were rejected, which I understand in two cases, since
the lines with + are already in the source:

>@@ -27,6 +27,7 @@
> import org.exist.storage.RangeIndexSpec;
> import org.exist.storage.StorageAddress;
> import org.exist.storage.serializers.Serializer;
>+import org.exist.util.sanity.SanityCheck;
> import org.exist.xquery.Cardinality;
> import org.exist.xquery.XPathException;
> import org.exist.xquery.value.AtomicValue;
>  
>

>@@ -1051,6 +1052,7 @@
>         if (nodeType != UNKNOWN_NODE_TYPE && nodeType != Node.ELEMENT_NODE)
>             return NodeSet.EMPTY_SET;
>         NodeImpl node = (NodeImpl) getNode();
>+        SanityCheck.ASSERT(node == null, "Node with gid " + gid + " not found!");
>         if (node.getNodeType() != Node.ELEMENT_NODE)
>             return NodeSet.EMPTY_SET;
>         AttrImpl attr = (AttrImpl)
>
But in this case I do not understand the rejection, the line with the -
is in the file and if I am not mistaken it should be replaced by the
line with the +

>@@ -184,7 +185,7 @@
>
> public int compareTo(Object other) {
> if(!(other instanceof NodeProxy))
>- throw new RuntimeException("cannot compare NodeProxy with " + other.getClass().getName());
>+ return 1;
> return compareTo((NodeProxy) other);
> }
>
>  
>
So I edited the file by hand and tried to compile a .war file, which
failed. I assume this is the one error mentioned at the end:

    [javac]
/home/uli/cvs.exist/snapshot_2005-10-26/src/org/exist/dom/NodeProxy.java:1056:
incompatible types
    [javac] found   : int
    [javac] required: org.exist.dom.NodeSet
    [javac]     return 1;
    [javac]                ^

So what should I do now? (I don't speak Java)

Uli



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Runtime exception in xquery with new snapshot

wolfgangmm
Hi,

> > public int compareTo(Object other) {
> >   if(!(other instanceof NodeProxy))
> >     return 1;
> >   return compareTo((NodeProxy) other);
> > }

> First all hunks were rejected, which I understand in two cases, since
> the lines with + are already in the source:

Maybe I created the patch from the wrong source (I have quite a lot of
different versions of the code on my machine). It seems you applied
the patch to the correct file.

> So I edited the file by hand and tried to compile a .war file, which
> failed. I assume this is the one error mentioned at the end:
>
>     [javac]
> /home/uli/cvs.exist/snapshot_2005-10-26/src/org/exist/dom/NodeProxy.java:1056:
> incompatible types
>     [javac] found   : int
>     [javac] required: org.exist.dom.NodeSet
>     [javac]     return 1;
>     [javac]                ^
Looks like you made the change in the wrong method. The method to be changed is:

public int compareTo(Object other) {
  if(!(other instanceof NodeProxy))
    return 1;
  return compareTo((NodeProxy) other);
}

which used to start on line 186. It should look exactly as above. To
make it simple, I attach my entire file.

Wolfgang

NodeProxy.java (43K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Runtime exception in xquery with new snapshot

Ulrike Schmidt
>
>
>To make it simple, I attach my entire file.
>  
>
Thanks a lot, now everything is working fine.

Uli



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open