Unexpected Exception in Query

I am running Stardog 5.2.3 (without reasoning) with the following query:

prefix irishTitle: <http://example.com/earlyIrishTitles.ttl#> 
prefix foaf: <http://xmlns.com/foaf/0.1/>

select distinct ?person ?king where {
  {
    ?a a foaf:Person.
    bind(count(?a) as ?person)
  } union {
    ?b a irishTitle:Rí.
    bind(count(?b) as ?king)
  }
}

When I ran this query, I received the following stacktrace in the logs:

ERROR 2018-05-05 13:00:40,085 [stardog-user-10] com.complexible.stardog.protocols.http.server.StardogHttpServiceLoader:accept(229): An unexpected exception was handled by the server
org.openrdf.query.QueryEvaluationException: null
        at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:81) ~[stardog-utils-rdf-5.2.3.jar:?]
        at org.openrdf.query.QueryResults.report(QueryResults.java:158) ~[sesame-query-4.0.0.jar:?]
        at org.openrdf.query.resultio.QueryResultIO.writeTuple(QueryResultIO.java:449) ~[sesame-queryresultio-api-4.0.0.jar:?]
        at com.complexible.stardog.protocols.http.server.ProtocolUtils.writeTupleResponse(ProtocolUtils.java:590) ~[stardog-protocols-http-server-5.2.3.jar:?]
        at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:497) ~[stardog-protocols-http-server-5.2.3.jar:?]
        at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:482) ~[stardog-protocols-http-server-5.2.3.jar:?]
        at com.complexible.stardog.protocols.http.server.SPARQLProtocol.executeQuery(SPARQLProtocol.java:134) ~[stardog-protocols-http-server-5.2.3.jar:?]
        at com.complexible.stardog.protocols.http.server.SPARQLProtocol.get(SPARQLProtocol.java:82) ~[stardog-protocols-http-server-5.2.3.jar:?]
        at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:196) ~[stardog-protocols-http-server-5.2.3.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 com.stardog.http.server.undertow.ErrorHandling.lambda$safeDispatch$1(ErrorHandling.java:71) ~[stardog-protocols-http-server-5.2.3.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_162]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_162]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_162]
Caused by: java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210) ~[guava-18.0.jar:?]
        at com.complexible.stardog.dht.dictionary.HashDictionary.getOrAddID(HashDictionary.java:532) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.dht.dictionary.HashDictionary.getID(HashDictionary.java:526) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.index.dictionary.DelegatingMappingDictionary.getID(DelegatingMappingDictionary.java:59) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.index.dictionary.InliningMappingDictionary.getID(InliningMappingDictionary.java:86) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.index.dictionary.DelegatingMappingDictionary.getID(DelegatingMappingDictionary.java:59) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.index.dictionary.QueryMappingDictionary.getID(QueryMappingDictionary.java:86) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.index.dictionary.QueryMappingDictionary.add(QueryMappingDictionary.java:70) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.BindOp.getId(BindOp.java:198) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.BindOp.bind(BindOp.java:170) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.BindOp.computeNext(BindOp.java:157) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.BindOp.computeNext(BindOp.java:37) ~[stardog-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.UnionOp.computeNext(UnionOp.java:82) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.UnionOp.computeNext(UnionOp.java:22) ~[stardog-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:70) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:29) ~[stardog-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.LazyUnsortedGroupify$1.computeNext(GroupifyAlgorithms.java:161) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.LazyUnsortedGroupify$1.computeNext(GroupifyAlgorithms.java:152) ~[stardog-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.AbstractGroupOp.computeNext(AbstractGroupOp.java:132) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.AbstractGroupOp.computeNext(AbstractGroupOp.java:31) ~[stardog-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.DistinctOp.computeNext(DistinctOp.java:53) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.impl.DistinctOp.computeNext(DistinctOp.java:21) ~[stardog-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:112) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:25) ~[stardog-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:110) ~[stardog-5.2.3.jar:?]
        at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:34) ~[stardog-5.2.3.jar:?]
        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143) ~[guava-18.0.jar:?]
        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138) ~[guava-18.0.jar:?]
        at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:77) ~[stardog-utils-rdf-5.2.3.jar:?]
        ... 14 more

Looks like there is a null pointer exception somewhere. You will need to download my database from github then use the foaf and relationship ontologies (http://purl.org/vocab/relationship/). There are a few ontologies that are in the github repo that you will also need to install as well.

Hi,

Any chance you can pack up all required ontologies in a single archive? Also, is it possible to zip up the Stardog database dir and make that available to us (the dir inside you STARDOG_HOME named as the database)?

Thanks,
Pavel

Hi Pavel,

No problem. I will produce a dump of the database from Stardog like last time and I will email it to you. There wil be a slight delay as it is on my home computer so I will need to wait until tonight.

Thanks!,
Chris

Hi Chris,

I was able to reproduce the problem. The issue is that the query isn’t syntactically valid, you cannot use aggregates, e.g. count, in a bind. We’ll improve the SPARQL parser to report it properly as a syntax error.

My guess is you probably need something like this instead:

select (count(distinct ?a) as ?person) (count(distinct ?b) as ?king) where {
{
  ?a a foaf:Person.
} union {
  ?b a irishTitle:Rí.
}
}

Cheers,
Pavel

Hi Pavel,

Great. Thanks. Yes, I did what you suggested but I wanted to report the exception as Stardog did not reject the query outright. Thank you for looking into it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.