You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Andy Seaborne <an...@apache.org> on 2014/05/05 21:15:51 UTC

Re: Reading TDB dataset in a union model

On 25/04/14 04:41, Karen Menz wrote:
(your message got dumped in my gmail spam folder)

> Hi,
>    I'm able to store a set of RDF/OWL files in a TDB dataset.
> Now, I wonder if there's a way to read this dataset back (by another application) into a union model of all files, to use the rich API for Model.
>
> This feature was supported by TDB-0.9.1, as:
> Model model = TDBFactory.createModel(directory);
>
> But now it's deprecated in Jena-2.11.1, which is the version I'm using.
>
> I'm trying the following:

Looks good

>
> Dataset ds = TDBFactory.createDataset(directory);
> ds.begin(ReadWrite.READ);
> Model model = ds.getDefaultModel();// null
> .......
> ds.close();
>
> and getting the following:
>
> Exception in thread "main" java.lang.NullPointerException
> at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.readPrefixMap(DatasetPrefixesTDB.java:174)

This suggests that at some time in the past, the database was used non 
transactionally and didn't shutdown cleanly.

You can try deleting the prefix map tables -- prefix*.*

> at com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.getNsPrefixMap(GraphPrefixesProjection.java:62)
> at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:223)
> at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:214)
> at com.hp.hpl.jena.tdb.store.GraphTDB.createPrefixMapping(GraphTDB.java:78)
> at com.hp.hpl.jena.graph.impl.GraphBase.getPrefixMapping(GraphBase.java:186)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.getPrefixMapping(ModelCom.java:980)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.withDefaultMappings(ModelCom.java:1024)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:74)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:70)
> at com.hp.hpl.jena.rdf.model.ModelFactory.createModelForGraph(ModelFactory.java:176)
> at com.hp.hpl.jena.sparql.core.DatasetImpl.graph2model(DatasetImpl.java:271)
> at com.hp.hpl.jena.sparql.core.DatasetImpl.getDefaultModel(DatasetImpl.java:103)
> at TestTDB.main(TestTDB.java:43)
>
>
> Thanks in advance,
>
> Karen
>


Re: Reading TDB dataset in a union model

Posted by Karen Menz <do...@yahoo.com>.
Thanks Andy, that works fine now.

Karen
On Monday, May 5, 2014 3:15 PM, Andy Seaborne <an...@apache.org> wrote:
 
On 25/04/14 04:41, Karen Menz wrote:
(your message got dumped in my gmail spam folder)

> Hi,
>    I'm able to store a set of RDF/OWL files in a TDB dataset.
> Now, I wonder if there's a way to read this dataset back (by another application) into a union model of all files, to use the rich API for Model.
>
> This feature was supported by TDB-0.9.1, as:
> Model model = TDBFactory.createModel(directory);
>
> But now it's deprecated in Jena-2.11.1, which is the version I'm using.
>
> I'm trying the following:

Looks good

>
> Dataset ds = TDBFactory.createDataset(directory);
> ds.begin(ReadWrite.READ);
> Model model = ds.getDefaultModel();// null
> .......
> ds.close();
>
> and getting the following:
>
> Exception in thread "main" java.lang.NullPointerException
> at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.readPrefixMap(DatasetPrefixesTDB.java:174)

This suggests that at some time in the past, the database was used non 
transactionally and didn't shutdown cleanly.

You can try deleting the prefix map tables -- prefix*.*


> at com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.getNsPrefixMap(GraphPrefixesProjection.java:62)
> at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:223)
> at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:214)
> at com.hp.hpl.jena.tdb.store.GraphTDB.createPrefixMapping(GraphTDB.java:78)
> at com.hp.hpl.jena.graph.impl.GraphBase.getPrefixMapping(GraphBase.java:186)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.getPrefixMapping(ModelCom.java:980)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.withDefaultMappings(ModelCom.java:1024)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:74)
> at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:70)
> at com.hp.hpl.jena.rdf.model.ModelFactory.createModelForGraph(ModelFactory.java:176)
> at com.hp.hpl.jena.sparql.core.DatasetImpl.graph2model(DatasetImpl.java:271)
> at com.hp.hpl.jena.sparql.core.DatasetImpl.getDefaultModel(DatasetImpl.java:103)
> at TestTDB.main(TestTDB.java:43)
>
>
> Thanks in advance,
>
> Karen
>