Chris,

Is the dataset TDB (from TDBFactory) or a dataset holding a model, maybe with added inference, where the base graph is backed by TDB?

It is better to put changes to the dataset inside a transaction. Failing that, it should be sync'ed -- TDB.sync().

    Andy

http://jena.staging.apache.org/documentation/txn/

On 27/02/18 18:33, Chris Wood wrote:
I've got a small application that follows the standard recommended pattern:

     // initialise dataset / model
     ...
     try {
         // ... add statements
         StmtIterator r = this.my_model.listStatements();
System.out.println(r.toList().size());
this.dataset.commit();
     } catch (SQLException e) {
         e.printStackTrace();
     } finally {
this.dataset.close();
     }

I was running this with Jena 3.0.1, and all was fine. I've just upgraded to
3.6.0. When I run the code and then check the tdb that is generated with
(on Windows):

      tdbquery --loc="database" "SELECT (count(*) as ?t) where {?a ?b ?c . }"

I get a NullPointerException:

Exception
java.lang.NullPointerException
         at
org.apache.jena.tdb.transaction.JournalControl.replay(JournalControl.java:280)
         at
org.apache.jena.tdb.transaction.JournalControl.recoverSegment(JournalControl.java:185)
         at
org.apache.jena.tdb.transaction.JournalControl.recoverFromJournal(JournalControl.java:137)
         at
org.apache.jena.tdb.StoreConnection.forceRecoverFromJournal(StoreConnection.java:150)
         at
org.apache.jena.tdb.StoreConnection._makeAndCache(StoreConnection.java:255)
         at
org.apache.jena.tdb.StoreConnection.make(StoreConnection.java:214)
         at
org.apache.jena.tdb.StoreConnection.make(StoreConnection.java:220)
         at
org.apache.jena.tdb.transaction.DatasetGraphTransaction.<init>(DatasetGraphTransaction.java:70)
         at org.apache.jena.tdb.sys.TDBMaker._create(TDBMaker.java:55)
         at
org.apache.jena.tdb.sys.TDBMaker.createDatasetGraphTransaction(TDBMaker.java:42)
         at
org.apache.jena.tdb.TDBFactory._createDatasetGraph(TDBFactory.java:89)
         at
org.apache.jena.tdb.TDBFactory.createDatasetGraph(TDBFactory.java:71)
         at org.apache.jena.tdb.TDBFactory.createDataset(TDBFactory.java:55)
         at tdb.cmdline.ModTDBDataset.createDataset(ModTDBDataset.java:103)
         at arq.cmdline.ModDataset.getDataset(ModDataset.java:36)
         at arq.query.getDataset(query.java:176)
         at arq.query.queryExec(query.java:213)
         at arq.query.exec(query.java:153)
         at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
         at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
         at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
         at tdb.tdbquery.main(tdbquery.java:33)

What seems really weird is that if I run the code *again* (without deleting
the dataset directory) the triplestore is populated.

  - If I run the code ensuring I use v3.0.1, this doesn't happen, and the
tdbquery command works on the first attempt.
  - The print statement showing the number of statements in the dataset
shows the correct number in all cases.

What has changed between 3.0.1 and 3.6.0 to cause this (and any hints on
what I need to do to resolve it would be greatly appreciated!)

Thanks
Chris

Reply via email to