openllet icon indicating copy to clipboard operation
openllet copied to clipboard

Exception SPARQL Query caused through wildcard

Open greeny277 opened this issue 8 years ago • 7 comments

Hey, I'm having a query which works quite fine in Protege but causes a Nullpointer Exception in Openllet. Its structure looks as following:

{?x rdfs:subClassOf [owl:intersectionOf [rdf:rest*/rdf:first [rdf:type owl:Restriction ; owl:onProperty :hasProp; owl:someValuesFrom ?result]]].}

I can say for sure that the wildcard symbol * causes this Exception, because it doesn't crash without it.

This is the stacktrace:

Exception in thread "main" java.lang.NullPointerException                                                                                                                                           
        at openllet.core.utils.ATermUtils.isVar(ATermUtils.java:1157)                       
        at openllet.query.sparqldl.model.QueryAtomImpl.<init>(QueryAtomImpl.java:59)                                                                                                                                                
        at openllet.query.sparqldl.model.QueryAtomImpl.<init>(QueryAtomImpl.java:45)             
        at openllet.query.sparqldl.model.QueryAtomFactory.TypeAtom(QueryAtomFactory.java:34)                                                                                                                                        
        at openllet.query.sparqldl.parser.ARQParser.parse(ARQParser.java:525)                                            
        at openllet.query.sparqldl.parser.ARQParser.parse(ARQParser.java:215)                                                                                                                                                       
        at openllet.query.sparqldl.jena.SparqlDLStage.parsePattern(SparqlDLStage.java:115)
        at openllet.query.sparqldl.jena.SparqlDLStage.build(SparqlDLStage.java:103)                                                                                                                                                 
        at openllet.query.sparqldl.jena.SparqlDLStageGenerator.execute(SparqlDLStageGenerator.java:49)
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:128)        
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:58)
        at org.apache.jena.sparql.algebra.op.OpBGP.visit(OpBGP.java:49)                         
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:117)         
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:228)         
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:130)
        at org.apache.jena.sparql.algebra.op.OpSequence.visit(OpSequence.java:75)      
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:117)         
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:228)                                                                                                                               
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:130)                                                                                                 
        at org.apache.jena.sparql.algebra.op.OpSequence.visit(OpSequence.java:75)             
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:117)                              
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:389)
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(ExecutionDispatch.java:267)                                                                                                                                   
        at org.apache.jena.sparql.algebra.op.OpProject.visit(OpProject.java:47)                                                                                                                                     
        at org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(ExecutionDispatch.java:46)                                                                                                             
        at org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:117)       
        at org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.java:88)                                                                                                                                                
        at org.apache.jena.sparql.engine.main.QC.execute(QC.java:52)                                            
        at org.apache.jena.sparql.engine.main.QueryEngineMain.eval(QueryEngineMain.java:55)                                                                                                                                         
        at org.apache.jena.sparql.engine.QueryEngineBase.evaluate(QueryEngineBase.java:136)                             
        at org.apache.jena.sparql.engine.QueryEngineBase.createPlan(QueryEngineBase.java:106)                                                                                                                                       
        at org.apache.jena.sparql.engine.QueryEngineBase.getPlan(QueryEngineBase.java:87)                              
        at org.apache.jena.sparql.engine.main.QueryEngineMain$QueryEngineMainFactory.create(QueryEngineMain.java:90)
        at org.apache.jena.sparql.engine.QueryExecutionBase.getPlan(QueryExecutionBase.java:524)
        at org.apache.jena.sparql.engine.QueryExecutionBase.startQueryIterator(QueryExecutionBase.java:472)
        at org.apache.jena.sparql.engine.QueryExecutionBase.execResultSet(QueryExecutionBase.java:511)
        at org.apache.jena.sparql.engine.QueryExecutionBase.execSelect(QueryExecutionBase.java:172)

Is this a known behaviour? Otherwise I'll try to provide a small example these days.

greeny277 avatar Nov 21 '17 18:11 greeny277

I don't think that SPARQL-DL supports SPARQL 1.1 property paths.

LorenzBuehmann avatar Nov 22 '17 11:11 LorenzBuehmann

Ok. I was just wondering why the SPARQL plugin by Protege can handle this query. Meanwhile i thought about replacing this intersectionOf with a bunch of subclassOf relations. So I guess this is no bug then?

greeny277 avatar Nov 22 '17 16:11 greeny277

Anything that end with that kind of Exception should be see as a bug. The tool should send at least a better error message.

I'm not very awar of how the sparql-query module work and maybe I have done a bad mistake somewhere.

What version are you using ?

Galigator avatar Nov 22 '17 16:11 Galigator

I'm currently using version 2.6.2.

greeny277 avatar Nov 22 '17 16:11 greeny277

@greeny277 Which SPARQL plugin do you use? Protege has two SPARQL plugins:

  1. The standard SPARQL query tab doesn't use Pellet and doesn't support DL reasoning. It uses RDF4J as SPARQL API and support property paths.
  2. The Snap SPARQL plugin uses its own parser + SPARQL DL API, but this plugin does not support Property Paths.
<dependency>
            <groupId>edu.stanford.protege</groupId>
            <artifactId>de-derivo-sparqldlapi</artifactId>
            <version>3.0.0</version>
        </dependency>

Pellet is using SPARQL DL which doesn't support property paths.

LorenzBuehmann avatar Nov 22 '17 17:11 LorenzBuehmann

I'm using the Standard SPARQL Query Plugin in Version 2.0.2.

greeny277 avatar Nov 22 '17 17:11 greeny277

Ok, as I said, this plugin uses RDF4J for SPARQL query processing. Regarding Pellet, its SPARQL query API was developed before SPARQL 1.1, so that might be the reason for missing support. At least I assume that the parser fails somehow. Maybe it's easy to fix, but somebody would have to dig into the code.

Your current query doesn't look like reasoning is necessary. You can use standard Apache Jena if you don't need OWL DL reasoning. Jena also supports some rule-based reasoning for different language profiles, maybe that would be sufficient just in case you need some light-weight reasoning.

LorenzBuehmann avatar Nov 22 '17 18:11 LorenzBuehmann