You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Mike Welch <mj...@verizonmedia.com.INVALID> on 2019/06/05 22:25:59 UTC

Configuring a TDB2 dataset with RDFS reasoning in Fuseki

Apologies for what feels like a near-dupe question from the past. I've seen
so many related questions, but can't quite get the assembler config nailed
down right.  I have:

1. A TDB2 dataset, with data spread between a few named graphs and the
default graph.
2. An external OWL ontology which I would like to use to infer additional
info about the data in (1).  For now, I'm only trying to infer class
hierarchy info based on RDFS subclassOf statements.

Snipping what I think are the relevant portions of the config file, I have:

-----------
<#service> rdf:type fuseki:Service ;
     fuseki:dataset           <#inf_dataset> .

<#inf_dataset> rdf:type ja:RDFDataset ;
    ja:defaultGraph <#model> .

<#model> rdf:type ja:InfModel ;
    ja:reasoner [ ja:reasonerURL <
http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ] ;
    ja:baseModel <#baseModel> .

<#baseModel> rdf:type ja:UnionModel ;
    ja:subModel <#ontology> ;
    ja:rootModel <#tdb_graph> .

<#ontology> rdf:type ja:MemoryModel ;
    ja:content [ ja:externalContent <file:////path/to/ontology.owl> ] .

<#tdb_graph> rdf:type tdb2:GraphTDB ;
    tdb2:dataset <#tdb2_dataset> .

<#tdb2_dataset> rdf:type tdb2:DatasetTDB2 ;
    tdb2:location "/path/to/graph" .
-----------

This configuration works for queries, including inference, on a small toy
dataset.  When pointed to the much larger "real" dataset, however, even a
simple query fails:

SELECT ?t
WHERE
{ ns:someId a ?t }

Throws this exception:

2019-06-05 22:19:17 [qtp322836221-75] WARN  org.apache.jena.fuseki.Fuseki -
[28] RC = 500 : Iterator used inside a different transaction
org.apache.jena.dboe.transaction.txn.TransactionException: Iterator used
inside a different transaction
        at
org.apache.jena.tdb2.store.IteratorTxnTracker.check(IteratorTxnTracker.java:53)
        at
org.apache.jena.tdb2.store.IteratorTxnTracker.hasNext(IteratorTxnTracker.java:41)
        at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
        at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:903)
        at
org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
        at
org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
        at
org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
        at
org.apache.jena.graph.compose.CompositionBase$1.hasNext(CompositionBase.java:94)
        at
org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
        at
org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
        at
org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
        at
org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
        at
org.apache.jena.reasoner.rulesys.impl.TopLevelTripleMatchFrame.nextMatch(TopLevelTripleMatchFrame.java:55)
        at
org.apache.jena.reasoner.rulesys.impl.LPInterpreter.run(LPInterpreter.java:328)
        at
org.apache.jena.reasoner.rulesys.impl.LPInterpreter.next(LPInterpreter.java:190)
        at
org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:252)
        at
org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:239)
        at
org.apache.jena.reasoner.rulesys.impl.LPBRuleEngine.pump(LPBRuleEngine.java:359)
        at
org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.moveForward(LPTopGoalIterator.java:107)
        at
org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.hasNext(LPTopGoalIterator.java:223)
        at
org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)

If I instead load the ontology.owl contents into the TDB2 dataset's default
graph and wire it up with baseModel pointing to that TDB2 graph, queries
succeed with inference even on the real dataset ==> but I would like to
keep the ontology definition separate from the data.

Any pointers would be much appreciated.

Thanks,
- Mike

Re: Configuring a TDB2 dataset with RDFS reasoning in Fuseki

Posted by Andy Seaborne <an...@apache.org>.
Thanks!

On 06/06/2019 20:57, Mike Welch wrote:
> Hi Andy,
> 
> I tried a slightly different configuration along the lines of what you
> suggested (I think), and encountered the same issues.  I was able to
> reproduce it with a small toy dataset/ontology and the fuseki/jena command
> line tools.  Filed a JIRA here with the steps:
> https://issues.apache.org/jira/browse/JENA-1719
> 
> Please let me know if you see something I'm doing wrong in the sample
> config or if you need more info.
> 
> Thanks!
> - Mike
> 
> 
> 
> On Thu, Jun 6, 2019 at 3:51 AM Andy Seaborne <an...@apache.org> wrote:
> 
>> Mike,
>>
>> This sounds related to JENA-1492 (but not exactly the same)
>> Which version are you using?
>>
>> Have you tried using ja:schema to keep the ontology separate?
>> http://jena.apache.org/documentation/assembler/assembler-howto
>> to configure the reasoner factory?
>>
>> """
>> Reasoner's optional ja:schema property specifies a Model which contains
>> the schema for the reasoner to be bound to.
>> """
>>
>> Also - maybe load the ontology from a file. I'm guessing the confusion
>> is that the ontology is being accessed independent of the data but being
>> in the same DB, there is transaction confusion.
>>
>>       Andy
>>
>> On 05/06/2019 23:25, Mike Welch wrote:
>>> Apologies for what feels like a near-dupe question from the past. I've
>> seen
>>> so many related questions, but can't quite get the assembler config
>> nailed
>>> down right.  I have:
>>>
>>> 1. A TDB2 dataset, with data spread between a few named graphs and the
>>> default graph.
>>> 2. An external OWL ontology which I would like to use to infer additional
>>> info about the data in (1).  For now, I'm only trying to infer class
>>> hierarchy info based on RDFS subclassOf statements.
>>>
>>> Snipping what I think are the relevant portions of the config file, I
>> have:
>>>
>>> -----------
>>> <#service> rdf:type fuseki:Service ;
>>>        fuseki:dataset           <#inf_dataset> .
>>>
>>> <#inf_dataset> rdf:type ja:RDFDataset ;
>>>       ja:defaultGraph <#model> .
>>>
>>> <#model> rdf:type ja:InfModel ;
>>>       ja:reasoner [ ja:reasonerURL <
>>> http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ] ;
>>>       ja:baseModel <#baseModel> .
>>>
>>> <#baseModel> rdf:type ja:UnionModel ;
>>>       ja:subModel <#ontology> ;
>>>       ja:rootModel <#tdb_graph> .
>>>
>>> <#ontology> rdf:type ja:MemoryModel ;
>>>       ja:content [ ja:externalContent <file:////path/to/ontology.owl> ] .
>>>
>>> <#tdb_graph> rdf:type tdb2:GraphTDB ;
>>>       tdb2:dataset <#tdb2_dataset> .
>>>
>>> <#tdb2_dataset> rdf:type tdb2:DatasetTDB2 ;
>>>       tdb2:location "/path/to/graph" .
>>> -----------
>>>
>>> This configuration works for queries, including inference, on a small toy
>>> dataset.  When pointed to the much larger "real" dataset, however, even a
>>> simple query fails:
>>>
>>> SELECT ?t
>>> WHERE
>>> { ns:someId a ?t }
>>>
>>> Throws this exception:
>>>
>>> 2019-06-05 22:19:17 [qtp322836221-75] WARN
>> org.apache.jena.fuseki.Fuseki -
>>> [28] RC = 500 : Iterator used inside a different transaction
>>> org.apache.jena.dboe.transaction.txn.TransactionException: Iterator used
>>> inside a different transaction
>>>           at
>>>
>> org.apache.jena.tdb2.store.IteratorTxnTracker.check(IteratorTxnTracker.java:53)
>>>           at
>>>
>> org.apache.jena.tdb2.store.IteratorTxnTracker.hasNext(IteratorTxnTracker.java:41)
>>>           at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>>>           at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:903)
>>>           at
>>>
>> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>>>           at
>>>
>> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>>>           at
>>>
>> org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
>>>           at
>>>
>> org.apache.jena.graph.compose.CompositionBase$1.hasNext(CompositionBase.java:94)
>>>           at
>>>
>> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
>>>           at
>>>
>> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>>>           at
>>>
>> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
>>>           at
>>>
>> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
>>>           at
>>>
>> org.apache.jena.reasoner.rulesys.impl.TopLevelTripleMatchFrame.nextMatch(TopLevelTripleMatchFrame.java:55)
>>>           at
>>>
>> org.apache.jena.reasoner.rulesys.impl.LPInterpreter.run(LPInterpreter.java:328)
>>>           at
>>>
>> org.apache.jena.reasoner.rulesys.impl.LPInterpreter.next(LPInterpreter.java:190)
>>>           at
>>> org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:252)
>>>           at
>>> org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:239)
>>>           at
>>>
>> org.apache.jena.reasoner.rulesys.impl.LPBRuleEngine.pump(LPBRuleEngine.java:359)
>>>           at
>>>
>> org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.moveForward(LPTopGoalIterator.java:107)
>>>           at
>>>
>> org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.hasNext(LPTopGoalIterator.java:223)
>>>           at
>>>
>> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>>>
>>> If I instead load the ontology.owl contents into the TDB2 dataset's
>> default
>>> graph and wire it up with baseModel pointing to that TDB2 graph, queries
>>> succeed with inference even on the real dataset ==> but I would like to
>>> keep the ontology definition separate from the data.
>>>
>>> Any pointers would be much appreciated.
>>>
>>> Thanks,
>>> - Mike
>>>
>>
> 

Re: Configuring a TDB2 dataset with RDFS reasoning in Fuseki

Posted by Mike Welch <mj...@verizonmedia.com.INVALID>.
Hi Andy,

I tried a slightly different configuration along the lines of what you
suggested (I think), and encountered the same issues.  I was able to
reproduce it with a small toy dataset/ontology and the fuseki/jena command
line tools.  Filed a JIRA here with the steps:
https://issues.apache.org/jira/browse/JENA-1719

Please let me know if you see something I'm doing wrong in the sample
config or if you need more info.

Thanks!
- Mike



On Thu, Jun 6, 2019 at 3:51 AM Andy Seaborne <an...@apache.org> wrote:

> Mike,
>
> This sounds related to JENA-1492 (but not exactly the same)
> Which version are you using?
>
> Have you tried using ja:schema to keep the ontology separate?
> http://jena.apache.org/documentation/assembler/assembler-howto
> to configure the reasoner factory?
>
> """
> Reasoner's optional ja:schema property specifies a Model which contains
> the schema for the reasoner to be bound to.
> """
>
> Also - maybe load the ontology from a file. I'm guessing the confusion
> is that the ontology is being accessed independent of the data but being
> in the same DB, there is transaction confusion.
>
>      Andy
>
> On 05/06/2019 23:25, Mike Welch wrote:
> > Apologies for what feels like a near-dupe question from the past. I've
> seen
> > so many related questions, but can't quite get the assembler config
> nailed
> > down right.  I have:
> >
> > 1. A TDB2 dataset, with data spread between a few named graphs and the
> > default graph.
> > 2. An external OWL ontology which I would like to use to infer additional
> > info about the data in (1).  For now, I'm only trying to infer class
> > hierarchy info based on RDFS subclassOf statements.
> >
> > Snipping what I think are the relevant portions of the config file, I
> have:
> >
> > -----------
> > <#service> rdf:type fuseki:Service ;
> >       fuseki:dataset           <#inf_dataset> .
> >
> > <#inf_dataset> rdf:type ja:RDFDataset ;
> >      ja:defaultGraph <#model> .
> >
> > <#model> rdf:type ja:InfModel ;
> >      ja:reasoner [ ja:reasonerURL <
> > http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ] ;
> >      ja:baseModel <#baseModel> .
> >
> > <#baseModel> rdf:type ja:UnionModel ;
> >      ja:subModel <#ontology> ;
> >      ja:rootModel <#tdb_graph> .
> >
> > <#ontology> rdf:type ja:MemoryModel ;
> >      ja:content [ ja:externalContent <file:////path/to/ontology.owl> ] .
> >
> > <#tdb_graph> rdf:type tdb2:GraphTDB ;
> >      tdb2:dataset <#tdb2_dataset> .
> >
> > <#tdb2_dataset> rdf:type tdb2:DatasetTDB2 ;
> >      tdb2:location "/path/to/graph" .
> > -----------
> >
> > This configuration works for queries, including inference, on a small toy
> > dataset.  When pointed to the much larger "real" dataset, however, even a
> > simple query fails:
> >
> > SELECT ?t
> > WHERE
> > { ns:someId a ?t }
> >
> > Throws this exception:
> >
> > 2019-06-05 22:19:17 [qtp322836221-75] WARN
> org.apache.jena.fuseki.Fuseki -
> > [28] RC = 500 : Iterator used inside a different transaction
> > org.apache.jena.dboe.transaction.txn.TransactionException: Iterator used
> > inside a different transaction
> >          at
> >
> org.apache.jena.tdb2.store.IteratorTxnTracker.check(IteratorTxnTracker.java:53)
> >          at
> >
> org.apache.jena.tdb2.store.IteratorTxnTracker.hasNext(IteratorTxnTracker.java:41)
> >          at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
> >          at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:903)
> >          at
> >
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> >          at
> >
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> >          at
> >
> org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
> >          at
> >
> org.apache.jena.graph.compose.CompositionBase$1.hasNext(CompositionBase.java:94)
> >          at
> >
> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
> >          at
> >
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> >          at
> >
> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
> >          at
> >
> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
> >          at
> >
> org.apache.jena.reasoner.rulesys.impl.TopLevelTripleMatchFrame.nextMatch(TopLevelTripleMatchFrame.java:55)
> >          at
> >
> org.apache.jena.reasoner.rulesys.impl.LPInterpreter.run(LPInterpreter.java:328)
> >          at
> >
> org.apache.jena.reasoner.rulesys.impl.LPInterpreter.next(LPInterpreter.java:190)
> >          at
> > org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:252)
> >          at
> > org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:239)
> >          at
> >
> org.apache.jena.reasoner.rulesys.impl.LPBRuleEngine.pump(LPBRuleEngine.java:359)
> >          at
> >
> org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.moveForward(LPTopGoalIterator.java:107)
> >          at
> >
> org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.hasNext(LPTopGoalIterator.java:223)
> >          at
> >
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> >
> > If I instead load the ontology.owl contents into the TDB2 dataset's
> default
> > graph and wire it up with baseModel pointing to that TDB2 graph, queries
> > succeed with inference even on the real dataset ==> but I would like to
> > keep the ontology definition separate from the data.
> >
> > Any pointers would be much appreciated.
> >
> > Thanks,
> > - Mike
> >
>

Re: Configuring a TDB2 dataset with RDFS reasoning in Fuseki

Posted by Andy Seaborne <an...@apache.org>.
Mike,

This sounds related to JENA-1492 (but not exactly the same)
Which version are you using?

Have you tried using ja:schema to keep the ontology separate?
http://jena.apache.org/documentation/assembler/assembler-howto
to configure the reasoner factory?

"""
Reasoner's optional ja:schema property specifies a Model which contains 
the schema for the reasoner to be bound to.
"""

Also - maybe load the ontology from a file. I'm guessing the confusion 
is that the ontology is being accessed independent of the data but being 
in the same DB, there is transaction confusion.

     Andy

On 05/06/2019 23:25, Mike Welch wrote:
> Apologies for what feels like a near-dupe question from the past. I've seen
> so many related questions, but can't quite get the assembler config nailed
> down right.  I have:
> 
> 1. A TDB2 dataset, with data spread between a few named graphs and the
> default graph.
> 2. An external OWL ontology which I would like to use to infer additional
> info about the data in (1).  For now, I'm only trying to infer class
> hierarchy info based on RDFS subclassOf statements.
> 
> Snipping what I think are the relevant portions of the config file, I have:
> 
> -----------
> <#service> rdf:type fuseki:Service ;
>       fuseki:dataset           <#inf_dataset> .
> 
> <#inf_dataset> rdf:type ja:RDFDataset ;
>      ja:defaultGraph <#model> .
> 
> <#model> rdf:type ja:InfModel ;
>      ja:reasoner [ ja:reasonerURL <
> http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ] ;
>      ja:baseModel <#baseModel> .
> 
> <#baseModel> rdf:type ja:UnionModel ;
>      ja:subModel <#ontology> ;
>      ja:rootModel <#tdb_graph> .
> 
> <#ontology> rdf:type ja:MemoryModel ;
>      ja:content [ ja:externalContent <file:////path/to/ontology.owl> ] .
> 
> <#tdb_graph> rdf:type tdb2:GraphTDB ;
>      tdb2:dataset <#tdb2_dataset> .
> 
> <#tdb2_dataset> rdf:type tdb2:DatasetTDB2 ;
>      tdb2:location "/path/to/graph" .
> -----------
> 
> This configuration works for queries, including inference, on a small toy
> dataset.  When pointed to the much larger "real" dataset, however, even a
> simple query fails:
> 
> SELECT ?t
> WHERE
> { ns:someId a ?t }
> 
> Throws this exception:
> 
> 2019-06-05 22:19:17 [qtp322836221-75] WARN  org.apache.jena.fuseki.Fuseki -
> [28] RC = 500 : Iterator used inside a different transaction
> org.apache.jena.dboe.transaction.txn.TransactionException: Iterator used
> inside a different transaction
>          at
> org.apache.jena.tdb2.store.IteratorTxnTracker.check(IteratorTxnTracker.java:53)
>          at
> org.apache.jena.tdb2.store.IteratorTxnTracker.hasNext(IteratorTxnTracker.java:41)
>          at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>          at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:903)
>          at
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>          at
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>          at
> org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
>          at
> org.apache.jena.graph.compose.CompositionBase$1.hasNext(CompositionBase.java:94)
>          at
> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
>          at
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>          at
> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
>          at
> org.apache.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:105)
>          at
> org.apache.jena.reasoner.rulesys.impl.TopLevelTripleMatchFrame.nextMatch(TopLevelTripleMatchFrame.java:55)
>          at
> org.apache.jena.reasoner.rulesys.impl.LPInterpreter.run(LPInterpreter.java:328)
>          at
> org.apache.jena.reasoner.rulesys.impl.LPInterpreter.next(LPInterpreter.java:190)
>          at
> org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:252)
>          at
> org.apache.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:239)
>          at
> org.apache.jena.reasoner.rulesys.impl.LPBRuleEngine.pump(LPBRuleEngine.java:359)
>          at
> org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.moveForward(LPTopGoalIterator.java:107)
>          at
> org.apache.jena.reasoner.rulesys.impl.LPTopGoalIterator.hasNext(LPTopGoalIterator.java:223)
>          at
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> 
> If I instead load the ontology.owl contents into the TDB2 dataset's default
> graph and wire it up with baseModel pointing to that TDB2 graph, queries
> succeed with inference even on the real dataset ==> but I would like to
> keep the ontology definition separate from the data.
> 
> Any pointers would be much appreciated.
> 
> Thanks,
> - Mike
>