Small world?
See https://issues.apache.org/jira/browse/JENA-234 (yesterday/today)
Workaround - try calling model.close() after TDBLoader.loadModel
Andy
On 13/04/12 14:26, Jim Reilly wrote:
I have been trying to load an OWL doc into TDB and get an error when I query
the DB after a JVM restart.
My load() method works, meaning the printAllQuery() shows the results.
But, when the JVM ends, and I re-start it, by just calling the
printAllQuery(), it gives me this error:
java.lang.NullPointerException at
com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.readPrefixMap(DatasetPrefixesTDB.java:175) at
com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.getNsPrefixMap(GraphPrefixesProjection.java:62)
at
com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:224)
at
com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:215)
at com.hp.hpl.jena.tdb.store.GraphTriplesTDB.createPrefixMapping(GraphTriplesTDB.java:99)
at com.hp.hpl.jena.sparql.graph.GraphBase2.getPrefixMapping(GraphBase2.java:194) at
com.hp.hpl.jena.rdf.model.impl.ModelCom.getPrefixMapping(ModelCom.java:908) at
com.hp.hpl.jena.rdf.model.impl.ModelCom.withDefaultMappings(ModelCom.java:952) at
com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:66) at
com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:62) at
com.hp.hpl.jena.rdf.model.ModelFactory.createModelForGraph(ModelFactory.java:166)
at com.hp.hpl.jena.sparql.core.DatasetImpl.graph2model(DatasetImpl.java:268)
at com.hp.hpl.jena.sparql.core.DatasetImpl.getDefaultModel(DatasetImpl.java:104)
So, is loading the OWL into memory and loading into TDB done differently
somehow...????
Also note, my prefixes.dat is empty.
Here is the shortened method I've been using to test:
public void load()
{
Dataset dataset = TDBFactory.assembleDataset("air-tdb-assembler.ttl");
Model model = dataset.getDefaultModel();
OntModel ontModel =
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RDFS_INF, model);
TDBLoader.loadModel(model, "file:src/test/resources/time.owl");
printAllQuery();
}
public void printAllQuery()
{
try
{
Query ALL_QUERY = QueryFactory.create("SELECT * {?s ?p ?o}");
QueryExecution qExec = QueryExecutionFactory.create(ALL_QUERY, dataset);
ResultSet rs = qExec.execSelect();
try
{
ResultSetFormatter.out(rs);
}
finally
{
qExec.close();
}
}
finally
{
// dataset.end(); // declares the end of the read transaction
}
}
air-tdb-assembler.ttl:
@prefix tdb:<http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja:<http://jena.hpl.hp.com/2005/11/Assembler#> .
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "target/jenaDatabase/jenaDS" ;
.
Tkx,
Jim