It looks like previously you were using the database withotu
transactions and didn't shutdown cleanly.
The database has been corrupted. You'll need to rebuild it.
The code below is fine - the problem happened beforehand and is only now
showing up.
Andy
On 03/03/2020 14:01, Diptendu Dutta wrote:
I am getting java.lang.StringIndexOutOfBoundsException while writing
RDF from a model (model.write()). I have tried with other mechanisms
such as RDFWriter, RDFDataMgr but I get exactly the same error.
Here is the code:
static public String getRDF(String corpus_file_id) {
String rdfString = null;
Model model = null;
dataset.begin(ReadWrite.READ) ;
try {
model = dataset.getNamedModel(corpus_file_id);
model.write(System.out, "RDF/XML");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
model.close();
dataset.end();
}
return rdfString;
}
java.lang.StringIndexOutOfBoundsException: String index out of range: 46
at java.lang.String.charAt(String.java:658)
at org.apache.jena.atlas.lib.StrUtils.decodeHex(StrUtils.java:212)
at org.apache.jena.tdb.store.nodetable.NodecSSE.decode(NodecSSE.java:121)
at org.apache.jena.tdb.lib.NodeLib.decode(NodeLib.java:120)
at org.apache.jena.tdb.lib.NodeLib.fetchDecode(NodeLib.java:97)
at
org.apache.jena.tdb.store.nodetable.NodeTableNative.readNodeFromTable(NodeTableNative.java:182)
at
org.apache.jena.tdb.store.nodetable.NodeTableNative._retrieveNodeByNodeId(NodeTableNative.java:108)
at
org.apache.jena.tdb.store.nodetable.NodeTableNative.getNodeForNodeId(NodeTableNative.java:67)
at
org.apache.jena.tdb.store.nodetable.NodeTableCache._retrieveNodeByNodeId(NodeTableCache.java:128)
at
org.apache.jena.tdb.store.nodetable.NodeTableCache.getNodeForNodeId(NodeTableCache.java:82)
at
org.apache.jena.tdb.store.nodetable.NodeTableWrapper.getNodeForNodeId(NodeTableWrapper.java:50)
at
org.apache.jena.tdb.store.nodetable.NodeTableInline.getNodeForNodeId(NodeTableInline.java:67)
at org.apache.jena.tdb.lib.TupleLib.quad(TupleLib.java:126)
at org.apache.jena.tdb.lib.TupleLib.quad(TupleLib.java:120)
at
org.apache.jena.tdb.lib.TupleLib.lambda$convertToQuads$3(TupleLib.java:59)
at org.apache.jena.atlas.iterator.Iter$2.next(Iter.java:352)
at org.apache.jena.atlas.iterator.Iter$2.next(Iter.java:352)
at org.apache.jena.atlas.iterator.Iter.next(Iter.java:1072)
at
org.apache.jena.util.iterator.WrappedIterator.next(WrappedIterator.java:94)
at org.apache.jena.util.iterator.Map1Iterator.next(Map1Iterator.java:46)
at org.apache.jena.util.iterator.NiceIterator.asSet(NiceIterator.java:208)
at org.apache.jena.util.iterator.NiceIterator.toSet(NiceIterator.java:199)
at org.apache.jena.graph.GraphUtil.listPredicates(GraphUtil.java:66)
at org.apache.jena.rdf.model.impl.ModelCom.listPredicates(ModelCom.java:999)
at
org.apache.jena.rdf.model.impl.ModelCom.listNameSpaces(ModelCom.java:1012)
at
org.apache.jena.rdfxml.xmloutput.impl.BaseXMLWriter.addNameSpaces(BaseXMLWriter.java:219)
at
org.apache.jena.rdfxml.xmloutput.impl.BaseXMLWriter.setupNamespaces(BaseXMLWriter.java:488)
at
org.apache.jena.rdfxml.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:470)
at
org.apache.jena.rdfxml.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:460)
at
org.apache.jena.riot.adapters.AdapterRDFWriter.write(AdapterRDFWriter.java:64)
at org.apache.jena.riot.RDFWriter.write$(RDFWriter.java:202)
at org.apache.jena.riot.RDFWriter.output(RDFWriter.java:161)
at org.apache.jena.riot.RDFWriter.output(RDFWriter.java:112)
at org.apache.jena.riot.RDFWriterBuilder.output(RDFWriterBuilder.java:205)
at org.apache.jena.riot.adapters.RDFWriterRIOT.write(RDFWriterRIOT.java:86)
at org.apache.jena.rdf.model.impl.ModelCom.write(ModelCom.java:379)
at knowledgegraph.JenaProcessor.getRDF(JenaProcessor.java:89)