Federated query issue

Dear,

We have encountered a issue within the federated queries of Stardog. We have a stardog instance on which we execute a federated query via Stardog Studio.

The Query:

SELECT *
WHERE {
SERVICE https://data.pdok.nl/sparql {
?vbo http://bag.basisregistraties.overheid.nl/def/bag#identificatiecode "0758010000090558" .
}
}

When we run the query we got the following error:

ERROR 2019-02-19 14:04:31,121 [stardog-user-1] com.complexible.stardog.protocols.http.server.StardogHttpServiceLoader:accept(235): An unexpected exception was handled by the server
com.stardog.stark.query.QueryExecutionFailure: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. [L1:1]
at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:82) ~[stardog-utils-rdf-6.1.0.jar:?]
at com.stardog.stark.query.ClosingSpliterator.forEachRemaining(ClosingSpliterator.java:37) ~[stardog-stark-query-api-6.1.0.jar:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[?:1.8.0_191]
at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:142) ~[stardog-stark-query-io-6.1.0.jar:?]
at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:127) ~[stardog-stark-query-io-6.1.0.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.writeTupleResponse(ProtocolUtils.java:579) ~[stardog-protocols-http-server-6.1.0.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:489) ~[stardog-protocols-http-server-6.1.0.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:474) ~[stardog-protocols-http-server-6.1.0.jar:?]
at com.complexible.stardog.protocols.http.server.SPARQLProtocol.executeQuery(SPARQLProtocol.java:127) ~[stardog-protocols-http-server-6.1.0.jar:?]
at com.complexible.stardog.protocols.http.server.SPARQLProtocol.post(SPARQLProtocol.java:91) ~[stardog-protocols-http-server-6.1.0.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-6.1.0.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.2.3.jar:1.2.3]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.2.3.jar:1.2.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_191]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
Caused by: com.complexible.stardog.plan.eval.operator.OperatorException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. [L1:1]
at com.complexible.stardog.plan.eval.service.SPARQLService$SparqlServiceQuery.evaluateBatch(SPARQLService.java:131) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.service.BatchingJoinArgServiceQuery.evaluate(BatchingJoinArgServiceQuery.java:59) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.ServiceOperatorImpl.computeNext(ServiceOperatorImpl.java:83) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.ServiceOperatorImpl.computeNext(ServiceOperatorImpl.java:34) ~[stardog-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:82) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:29) ~[stardog-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:112) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:25) ~[stardog-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:116) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:39) ~[stardog-6.1.0.jar:?]
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-26.0-jre.jar:?]
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-26.0-jre.jar:?]
at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:78) ~[stardog-utils-rdf-6.1.0.jar:?]
... 15 more
Caused by: com.stardog.stark.query.io.InvalidQueryResults: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. [L1:1]
at com.stardog.stark.query.io.xml.SAXErrorHandler.fatalError(SAXErrorHandler.java:71) ~[stardog-stark-query-xml-6.1.0.jar:?]
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at com.stardog.stark.query.io.xml.SimpleSAXParser.parse(SimpleSAXParser.java:221) ~[stardog-stark-query-xml-6.1.0.jar:?]
at com.stardog.stark.query.io.xml.SimpleSAXParser.parse(SimpleSAXParser.java:196) ~[stardog-stark-query-xml-6.1.0.jar:?]
at com.stardog.stark.query.io.xml.SPARQLXMLSelectResultParser.parse(SPARQLXMLSelectResultParser.java:78) ~[stardog-stark-query-xml-6.1.0.jar:?]
at com.stardog.stark.query.io.xml.SPARQLXMLSelectResultParser.parse(SPARQLXMLSelectResultParser.java:37) ~[stardog-stark-query-xml-6.1.0.jar:?]
at com.stardog.stark.query.io.QueryResultParsers.read(QueryResultParsers.java:307) ~[stardog-stark-query-io-6.1.0.jar:?]
at com.stardog.stark.query.io.QueryResultParsers.readSelect(QueryResultParsers.java:146) ~[stardog-stark-query-io-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.service.SPARQLService$SparqlServiceQuery.evaluateBatch(SPARQLService.java:124) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.service.BatchingJoinArgServiceQuery.evaluate(BatchingJoinArgServiceQuery.java:59) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.ServiceOperatorImpl.computeNext(ServiceOperatorImpl.java:83) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.ServiceOperatorImpl.computeNext(ServiceOperatorImpl.java:34) ~[stardog-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:82) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:29) ~[stardog-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:112) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:25) ~[stardog-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:116) ~[stardog-6.1.0.jar:?]
at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:39) ~[stardog-6.1.0.jar:?]
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-26.0-jre.jar:?]
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-26.0-jre.jar:?]
at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:78) ~[stardog-utils-rdf-6.1.0.jar:?]
... 15 more

Our first thought would be that stardog expects XML but does not get XML and therefore encounters a SAX error.
With help of a proxy we extracted following curl statement from stardog to the sparql endpoint:

curl -X GET "https://data.pdok.nl/sparql?query=SELECT+%3Fvbo+ WHERE+{ ++%3Fvbo+<http%3A%2F%2Fbag.basisregistraties.overheid.nl%2Fdef%2Fbag%23identificatiecode>+"0758010000090558" }&quot; -v -H "Accept: application/sparql-results+xml;q=0.9, application/sparql-results+json;q=0.9, text/csv;q=0.8, text/tab-separated-values;q=0.8, application/x-binary-rdf-results-table;q=0.8"

The curl statement return sparql results as json, which explains why stardog gives a SAX error.

We also tried a federated on wiki data. This works fine. If we do the same exercise we find that wikidata return sparql results as a xml. It seems that stardog does not process the results right, although the accept header contains sparql results in json.

You might want to check your query. I get a malformed query response. I haven't had to unencoded it yet to see what the problem might be.

The url encoding was a little off. This returns results. Give it a try

curl -X GET "https://data.pdok.nl/sparql?query=SELECT%20%3Fvbo%20WHERE%20%7B%20%3Fvbo%20%3Chttp%3A%2F%2Fbag.basisregistraties.overheid.nl%2Fdef%2Fbag%23identificatiecode%3E%20%220758010000090558%22%20%7D%0A" -v -H "Accept: application/sparql-results+xml;q=0.9, application/sparql-results+json;q=0.9, text/csv;q=0.8, text/tab-separated-values;q=0.8, application/x-binary-rdf-results-table;q=0.8"

It is returning JSON results, but Stardog seems to be misinterpreting them. I will investigate further and report back here when I find something

@zachary.whitley The query does work, thats not the issue.

@stephen Thats exactly what we think as well. Thanks!

Well you just must be super lucky because the query you supplied returns the following for me.

MALFORMED QUERY: Encountered "<EOF>" at line 1, column 12.
Was expecting one of:
    "(" ...
    "{" ...

@zachary.whitley it was doing that for me as well until I removed the newlines. Probably some weird invisible characters coming over from discourse or something.

@zachary.whitley Uhmm, I see. Probably some copy paste thing....

An update: We have discovered the root cause of this issue, and it will be fixed in the upcoming 6.1.2 release.

1 Like

Thanks! Stephan for your help.