Exist: Getting "ERROR isSameNode(Node other) not implemented on other class org.exist.dom.persistent.DocumentImpl"

Created on 8 Mar 2017  路  26Comments  路  Source: eXist-db/exist

This is something that was working with eXist-db version 3.0RC2 and doesn't work anymore with 3.1.0.

When executing an XQuery, from eXide for instance, there is an issue with the instruction :

transform:transform(
 doc($xmlFileUri), 
 doc(concat($xsltPath, '/', 'FancyTreeVisuDeclB30.xsl')), $params
)

We get this in return :
exerr:ERROR Exception while transforming node: isSameNode(Node other) not implemented on other class org.exist.dom.persistent.DocumentImpl

When debugging an execution of our application embeddind eXist, we have seen that this message is coming from the method is SameNode of class ElementImpl :

    @Override
    public boolean isSameNode(final Node other) {
        // This function is used by Saxon in some circumstances, and this partial implementation is required for proper Saxon operation.
        if(other instanceof IStoredNode) {
            return (this.nodeId == ((IStoredNode<?>) other).getNodeId() &&
                this.ownerDocument.getDocId() == ((IStoredNode<? extends IStoredNode>) other).getOwnerDocument().getDocId());
        }
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
            "isSameNode(Node other) not implemented on other class " + other.getClass().getName());
    }

So it seems that DocumentImpl should implement IStoredNode...

Context information

[eXist Version : 3.1.0]
[eXist Build : 20170307214949]
[Git commit : c679cd8]
[Operating System : Windows Server 2008 R2 6.1 amd64]

All 26 comments

Adding the console trace

org.xmldb.api.base.XMLDBException: exerr:ERROR Exception while transforming node: isSameNode(Node other) not implemented on other class org.exist.dom.persistent.DocumentImpl [at line 47, column 6]
    at org.exist.xmldb.LocalXPathQueryService.execute(LocalXPathQueryService.java:195)
    at org.exist.xmldb.LocalXPathQueryService.lambda$doQuery$0(LocalXPathQueryService.java:151)
    at org.exist.xmldb.function.LocalXmldbFunction.apply(LocalXmldbFunction.java:46)
    at org.exist.xmldb.AbstractLocal.withDb(AbstractLocal.java:195)
    at org.exist.xmldb.LocalXPathQueryService.doQuery(LocalXPathQueryService.java:145)
    at org.exist.xmldb.LocalXPathQueryService.query(LocalXPathQueryService.java:120)
    at org.exist.xmldb.LocalXPathQueryService.query(LocalXPathQueryService.java:109)
    at com.lswe.irisportail.irisweb.existdb.DbHandler.execQueryToResource(DbHandler.java:1053)
    at com.lswe.irisportail.irisweb.existdb.DbHandler.execQueryToResource(DbHandler.java:1146)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100)
    at org.jboss.weld.proxies.IDbHandler$10714142$Proxy$_$$_WeldClientProxy.execQueryToResource(Unknown Source)
    at com.lswe.irisportail.irisweb.existdb.QueryHandler.execQueryFromStringToString(QueryHandler.java:104)
    at com.lswe.irisportail.irisweb.existdb.QueryHandler$Proxy$_$$_WeldClientProxy.execQueryFromStringToString(Unknown Source)
    at com.lswe.irisportail.irisweb.dsn.dao.DsnVisuDeclarIndivDAO.getDeclIndForDeclProd(DsnVisuDeclarIndivDAO.java:152)
    at com.lswe.irisportail.irisweb.dsn.dao.DsnVisuDeclarIndivDAO$Proxy$_$$_WeldClientProxy.getDeclIndForDeclProd(Unknown Source)
    at com.lswe.irisportail.irisweb.dsn.service.impl.DsnVisuDeclarIndivS.getDeclIndForDeclProd(DsnVisuDeclarIndivS.java:26)
    at com.lswe.irisportail.irisweb.dsn.service.impl.DsnVisuDeclarIndivS$Proxy$_$$_WeldClientProxy.getDeclIndForDeclProd(Unknown Source)
    at com.lswe.irisportail.irisweb.dsn.action.DsnVisuDeclarIndivAction.getNodesList(DsnVisuDeclarIndivAction.java:270)
    at com.lswe.irisportail.irisweb.dsn.action.servlet.DsnTree.process(DsnTree.java:72)
    at com.lswe.irisportail.irisweb.dsn.action.servlet.DsnVisuTreeServlet.doGet(DsnVisuTreeServlet.java:33)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.lswe.irisportail.irisweb.filter.ExternalAuthenticationFilter.doFilter(ExternalAuthenticationFilter.java:155)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.lswe.irisportail.irisweb.filter.UTF8Filter.doFilter(UTF8Filter.java:33)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:198)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:176)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.exist.xquery.XPathException: exerr:ERROR Exception while transforming node: isSameNode(Node other) not implemented on other class org.exist.dom.persistent.DocumentImpl [at line 47, column 6]
    at org.exist.xquery.functions.transform.Transform.eval(Transform.java:261)
    at org.exist.xquery.BasicFunction.eval(BasicFunction.java:74)
    at org.exist.xquery.InternalFunctionCall.eval(InternalFunctionCall.java:41)
    at org.exist.xquery.DebuggableExpression.eval(DebuggableExpression.java:58)
    at org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:102)
    at org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:100)
    at org.exist.xquery.DebuggableExpression.eval(DebuggableExpression.java:58)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111)
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111)
    at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
    at org.exist.xquery.PathExpr.eval(PathExpr.java:276)
    at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
    at org.exist.xquery.XQuery.execute(XQuery.java:253)
    at org.exist.xquery.XQuery.execute(XQuery.java:185)
    at org.exist.xmldb.LocalXPathQueryService.execute(LocalXPathQueryService.java:192)
    ... 60 more
Caused by: org.w3c.dom.DOMException: isSameNode(Node other) not implemented on other class org.exist.dom.persistent.DocumentImpl
    at org.exist.dom.persistent.ElementImpl.isSameNode(ElementImpl.java:1744)
    at net.sf.saxon.dom.DOMNodeWrapper.getSuccessorNode(DOMNodeWrapper.java:934)
    at net.sf.saxon.dom.DOMNodeWrapper.getSuccessorElement(DOMNodeWrapper.java:899)
    at net.sf.saxon.dom.DOMNodeWrapper.getSuccessorElement(DOMNodeWrapper.java:41)
    at net.sf.saxon.tree.util.SteppingNavigator$FollowingElementStepper.step(SteppingNavigator.java:157)
    at net.sf.saxon.tree.util.SteppingNavigator$DescendantAxisIterator.next(SteppingNavigator.java:270)
    at net.sf.saxon.tree.util.SteppingNavigator$DescendantAxisIterator.next(SteppingNavigator.java:197)
    at net.sf.saxon.expr.ItemMappingIterator.next(ItemMappingIterator.java:90)
    at net.sf.saxon.trans.KeyManager.constructIndex(KeyManager.java:306)
    at net.sf.saxon.trans.KeyManager.buildIndex(KeyManager.java:260)
    at net.sf.saxon.trans.KeyManager.obtainSharedIndex(KeyManager.java:624)
    at net.sf.saxon.trans.KeyManager.obtainIndex(KeyManager.java:589)
    at net.sf.saxon.trans.KeyManager.selectByKey(KeyManager.java:527)
    at net.sf.saxon.functions.KeyFn.iterate(KeyFn.java:338)
    at net.sf.saxon.expr.SlashExpression.iterate(SlashExpression.java:842)
    at net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:180)
    at net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:28)
    at net.sf.saxon.functions.Concat.evaluateItem(Concat.java:88)
    at net.sf.saxon.functions.Concat.evaluateItem(Concat.java:32)
    at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:396)
    at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:34)
    at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:275)
    at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:30)
    at net.sf.saxon.expr.instruct.Choose.evaluateItem(Choose.java:872)
    at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:396)
    at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:34)
    at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:275)
    at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:30)
    at net.sf.saxon.expr.Expression.evaluateAsString(Expression.java:524)
    at net.sf.saxon.expr.instruct.SimpleNodeConstructor.processLeavingTail(SimpleNodeConstructor.java:216)
    at net.sf.saxon.expr.instruct.ValueOf.processLeavingTail(ValueOf.java:280)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389)
    at net.sf.saxon.expr.instruct.Template.expand(Template.java:367)
    at net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:496)
    at net.sf.saxon.trans.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:67)
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1100)
    at net.sf.saxon.Controller.transformDocument(Controller.java:2106)
    at net.sf.saxon.Controller.transform(Controller.java:1704)
    at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:547)
    at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:177)
    at net.sf.saxon.jaxp.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:173)
    at org.exist.util.serializer.ReceiverToSAX.endDocument(ReceiverToSAX.java:81)
    at org.exist.storage.serializers.XIncludeFilter.endDocument(XIncludeFilter.java:159)
    at org.exist.storage.serializers.Serializer.toSAX(Serializer.java:946)
    at org.exist.xquery.functions.transform.Transform.eval(Transform.java:258)
    ... 79 more

You should use w3c node, not existdb node (Document, Element, Node, etc)

@alebastrov org.w3c.dom.Node is just an interface

Yes, after getting content of node or whole document you should build w3c node/document like here
http://www.journaldev.com/1237/java-convert-string-to-xml-document-and-xml-document-to-string

@ebouladier It is unlikely that what you are describing previously worked in eXist-db as only ElementImpl previously implemented isSameNode. Could you try with this branch please: https://github.com/adamretter/exist/tree/hotfix/isSameNode

@alebastrov I think you are mistaken.

@adamretter I'm sure of the fact that there is no problem with the 3.0 RC2 because we currently have a customer using this release in production mode. Many others use the 2.2 without any problems too. And from our side it's the same XQuery and XSLT code. But all use Java 7.
We are not able to try with the proposed branch because we are not tooled to build the project from source and I'm sorry of that. Perhaps could you give me a link to a binary version ?

Thank you very much. I will inform you about the result of the try ASAP.

It seems that we are going a little further. When we execute our Xquery/XSLT from eXide, now the process sends the same message but coming from another class :
<exception> <path>/db/agd/visuBlocB30.xqy</path> <message> exerr:ERROR Exception while transforming node: isSameNode(Node other) not implemented on class org.exist.dom.persistent.TextImpl [at line 47, column 6] </message> </exception>

Hoping that this make sens to you.

@ebouladier Actually no that makes no sense whatsoever. As org.exist.dom.persistent.TextImpl certainly does implement isSameNode(Node) in that branch I gave you the build form.

Just to be certain, can you check again that you are definitely using the build I created for you?

Here after the check with other information.

2017-04-24 17:53:53,687 [main] INFO  (XmlLibraryChecker.java [check]:149) - Looking for a valid Parser...
Checking for Xerces, found version Xerces-J 2.11.0
OK!

2017-04-24 17:53:54,139 [main] INFO  (XmlLibraryChecker.java [check]:171) - Looking for a valid Transformer...
Checking for Saxon, found version 9.6.0.7
OK!

2017-04-24 17:53:54,139 [main] INFO  (XmlLibraryChecker.java [check]:183) - Looking for a valid Resolver...
Checking for Resolver, found version XmlResolver 1.2
OK!

2017-04-24 17:53:54,155 [main] INFO  (XmlLibraryChecker.java [check]:189) - Using parser org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser 
2017-04-24 17:53:54,155 [main] INFO  (XmlLibraryChecker.java [check]:190) - Using transformer net.sf.saxon.jaxp.IdentityTransformer 
2017-04-24 17:53:54,155 [main] INFO  (JettyStart.java [run]:133) - Running with Java 1.8.0_121 [Oracle Corporation (Java HotSpot(TM) 64-Bit Server VM) in C:\Talentia\java\jdk1.8\jre] 
2017-04-24 17:53:54,155 [main] INFO  (JettyStart.java [run]:140) - Running as user 'VM-HR-INFINITY$' 
2017-04-24 17:53:54,171 [main] INFO  (JettyStart.java [run]:141) - [eXist Home : .] 
2017-04-24 17:53:54,171 [main] INFO  (JettyStart.java [run]:142) - [eXist Version : 3.2.0-SNAPSHOT] 
2017-04-24 17:53:54,171 [main] INFO  (JettyStart.java [run]:143) - [eXist Build : 20170424133019] 
2017-04-24 17:53:54,171 [main] INFO  (JettyStart.java [run]:144) - [Git commit : cc87967] 
2017-04-24 17:53:54,171 [main] INFO  (JettyStart.java [run]:146) - [Operating System : Windows Server 2008 R2 6.1 amd64] 

it is probably interesting to see the correlated full stacktrace in exist.log of

Exception while transforming node: isSameNode(Node other) not implemented on class org.exist.dom.persistent.TextImpl

@dizzzz fix that @adamretter did have bug. Proper fix is here https://github.com/eXist-db/exist/pull/1349 ... but nobody of "core" developers interesting in it, just asking people this and that -(

I've attached a very detailed log (put "org.exist" in trace mode). Hope that will help.
exist.log.txt

yes, tnx

(how could I have missed your stacktrace.......)

@ebouladier @dizzzz The stacktrace was very helpful. Could you now try these builds which should fix the issue:

http://static.adamretter.org.uk/eXist-db-3.2.0-SNAPSHOT+20170425122627.dmg
or
http://static.adamretter.org.uk/eXist-db-setup-3.2.0-SNAPSHOT+20170425122627.jar

I've just tried your last build and it's working fine. Thank you very much.
We are now going to continue our tests with this build, waiting for the next stable release.

@ebouladier Excellent.

@shabanovd Not at all. I did look at your PR, but it contains much more than just this simple fix. Also the test which is there for this fix does not actually seem to test the changes. By running the XSLT in your test I was unable to actually trigger the code path which lead to isSameNode.

@adamretter that is very funny because the test fail for me and @RemiKoutcherawy as reported here https://github.com/eXist-db/exist/issues/1325 ... 2 vs 1 ;-)

@shabanovd I am not sure of your point. When I said your test did not exercise isSameNode I was talking about this test you wrote - https://github.com/eXist-db/exist/pull/1349/files#diff-ede73efa2260d94d3434c2b656b4ab5fR54 Whilst the test does pass, it does not actually call isSameNode and so does not cover the issue reported in #1337

To be clear I am not trying to fix the issue in #1325 and I haven't claimed to do so. I am just trying to fix the smaller issue described in #1337.

@adamretter why are you doing something that already was done? what for?

I see this as contempt to @RemiKoutcherawy's time and efforts (as minimum) and that makes me very sad.

@shabanovd I think you are confused. I am trying to repair the issue reported by @ebouladier (#1337) and not @RemiKoutcherawy (#1325). There may be some overlap, but it makes forward progress for both issues, so everyone should be happy.

We could not yet merge your https://github.com/eXist-db/exist/pull/1349 because a) it is blocked on https://github.com/eXist-db/exist/pull/1316 and b) it combines several different changes which don't directly address the issue.

However we could easily merge https://github.com/eXist-db/exist/pull/1426 which fixes this issue, is clean, has tests and is nicely self-container. It also makes progress toward a final fix for @RemiKoutcherawy

@adamretter by merging #1426 you throw out all time that was spend on #1349 (that have only 3 commits: fix, test and concurrent issue fix).

Please, explain, where I was wrong by saying that you (personally) give no respect to people time?
At the moment when you said that you do not understand #1316 (and you do not trust to me or @RemiKoutcherawy report that PR fix the issue) or at moment when #1426 will be merged?

you said that you do not understand #1316 (and you do not trust to me or @RemiKoutcherawy report that PR fix the issue

@shabanovd I have said neither thing; this conversation is not constructive.

Was this page helpful?
0 / 5 - 0 ratings