I have the following code
public class JenaProcessor {
static Dataset dataset = null;
static String ns = "http://www.lke.com/lke.owl#";
static {
try {
dataset = TDBFactory.createDataset("C:\\Users\\Diptendu\\Desktop\\lke");
}
catch(Exception ex) {
ex.printStackTrace();
}
}
static public void clearKnowledgeGraph(String corpus_file_id) {
dataset.begin(ReadWrite.WRITE) ;
Model model = null;
try {
model = dataset.getNamedModel(corpus_file_id);
model.removeAll();
dataset.commit();
if( model != null ) model.close();
}
catch(Exception ex) {
ex.printStackTrace();
}
finally {
dataset.end();
}
}
}
model.close() is causing the error TDBTransactionException: Not in a
transaction
org.apache.jena.tdb.transaction.TDBTransactionException: Not in a
transaction
at
org.apache.jena.tdb.transaction.DatasetGraphTransaction.get(DatasetGraphTransaction.java:138)
at
org.apache.jena.tdb.transaction.DatasetGraphTransaction.getDatasetGraphToQuery(DatasetGraphTransaction.java:84)
at
org.apache.jena.tdb.store.GraphTxnTDB.getDatasetGraphTDB(GraphTxnTDB.java:51)
at org.apache.jena.tdb.store.GraphTDB.sync(GraphTDB.java:128)
at org.apache.jena.tdb.store.GraphTDB.close(GraphTDB.java:133)
at org.apache.jena.rdf.model.impl.ModelCom.close(ModelCom.java:1494)
at knowledgegraph.JenaProcessor.clearKnowledgeGraph(JenaProcessor.java:120)
What do I need to do?
Regards,
Diptendu Dutta