The ontmodel is obtained inside a transaction. And here is my code for
the writing transaction and reading transaction:

WRITE:
ds.begin ( ReadWrite.WRITE );
                        ontmodel=ds.getNamedModel(graphURI_);
                        try{
                                Resource subject =
ontmodel.getResource(prefix_+subjectIndividualName);
                                Property datatypeProperty =
ontmodel.getProperty(prefix_+dataTypePropertyName);
                                Property propertyRange =
ontmodel.getProperty(rdfs_ + "range");
                                if
(ontmodel.getProperty(datatypeProperty,propertyRange) != null){
                                String typeURI =
ontmodel.getRequiredProperty(datatypeProperty,
propertyRange).getObject().toString();
                                Literal objectLiteral =
ontmodel.createTypedLiteral(value, typeURI);
                                Statement s1 =
ontmodel.createStatement(subject, datatypeProperty,
objectLiteral);
                                ontmodel.add(s1);
                        }
                        else{
                                Literal objectLiteral =
ontmodel.createLiteral(value);
                                Statement s1 =
ontmodel.createStatement(subject, datatypeProperty,
objectLiteral);
                                ontmodel.add(s1);
                        }

                        ds.commit();

                        }
                        finally { ds.end();

Read:

                                ds.begin(ReadWrite.READ);
                                try{
                                        ontmodel=ds.getNamedModel(graphURI_);
                                        ontmodel.write(new FileOutputStream(new 
File(path+filename)));                                  
                                }
                                finally{ds.end();}

Another question about this is that if this error has happened to the
TDB, is there any way to fix the data as otherwise I will lose all the
data?

Thank you very much.
Jie

On 19 March 2013 18:49, Andy Seaborne <[email protected]> wrote:
> On 19/03/13 15:40, Jie wrote:
>>
>> I am using the version tdb 0.9.4 and jena 2.7.4 and also I use
>> transactions in my code.
>
>
> Could you show more of your code?
>
> Is the ontmodel_ obtained inside a transaction?
>
> The corruption to the node table most likely happened in the past - it's the
> read operation detecting the problem, not causing it.
>
>         Andy
>
>
>>
>> On 19 March 2013 16:29, Andy Seaborne <[email protected]> wrote:
>>>
>>> On 19/03/13 15:25, Jie wrote:
>>>>
>>>>
>>>> Hello, everyone,
>>>>
>>>
>>> Which version are you running?
>>>
>>>
>>>> when I call the following method:
>>>> ontmodel_.write(new FileOutputStream(new File(path+filename)));
>>>>
>>>> I have got an error as following several times, if anyone can tell me
>>>> what is the possible reason for this? thank you very much.
>>>
>>>
>>>
>>> The node table is corrupt.  This is usually caused by not closing the
>>> database down cleanly when used non-transactionally.  In old versions,
>>> some
>>> concurrency problems could also cause thsi as well, but this is now
>>> presumed
>>> fixed.
>>>
>>>          Andy
>>>
>>>
>>>>
>>>> Caused by: com.hp.hpl.jena.tdb.base.file.FileException:
>>>>
>>>>
>>>> ObjectFileStorage.read[nodes.dat](30957333)[filesize=31344403][file.size()=31344403]:
>>>> Impossibly large object : 4537448 bytes >
>>>> filesize-(loc+SizeOfInt)=387066
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.base.objectfile.ObjectFileStorage.read(ObjectFileStorage.java:346)
>>>>          at com.hp.hpl.jena.tdb.lib.NodeLib.fetchDecode(NodeLib.java:78)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableNative.readNodeFromTable(NodeTableNative.java:178)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableNative._retrieveNodeByNodeId(NodeTableNative.java:103)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableNative.getNodeForNodeId(NodeTableNative.java:74)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableCache._retrieveNodeByNodeId(NodeTableCache.java:103)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableCache.getNodeForNodeId(NodeTableCache.java:74)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper.getNodeForNodeId(NodeTableWrapper.java:55)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableInline.getNodeForNodeId(NodeTableInline.java:67)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper.getNodeForNodeId(NodeTableWrapper.java:55)
>>>>          at com.hp.hpl.jena.tdb.lib.TupleLib.quad(TupleLib.java:161)
>>>>          at com.hp.hpl.jena.tdb.lib.TupleLib.quad(TupleLib.java:153)
>>>>          at
>>>> com.hp.hpl.jena.tdb.lib.TupleLib.access$100(TupleLib.java:45)
>>>>          at com.hp.hpl.jena.tdb.lib.TupleLib$4.convert(TupleLib.java:87)
>>>>          at com.hp.hpl.jena.tdb.lib.TupleLib$4.convert(TupleLib.java:83)
>>>>          at org.openjena.atlas.iterator.Iter$4.next(Iter.java:301)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.store.GraphTDBBase$ProjectQuadsToTriples.next(GraphTDBBase.java:178)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.tdb.store.GraphTDBBase$ProjectQuadsToTriples.next(GraphTDBBase.java:166)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.util.iterator.WrappedIterator.next(WrappedIterator.java:80)
>>>>          at
>>>> com.hp.hpl.jena.util.iterator.NiceIterator$1.next(NiceIterator.java:120)
>>>>          at
>>>> com.hp.hpl.jena.util.iterator.NiceIterator$1.next(NiceIterator.java:120)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.graph.query.SimpleQueryHandler.predicatesFor(SimpleQueryHandler.java:86)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.graph.query.SimpleQueryHandler.predicatesFor(SimpleQueryHandler.java:64)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.rdf.model.impl.ModelCom.listPredicates(ModelCom.java:889)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.rdf.model.impl.ModelCom.listNameSpaces(ModelCom.java:902)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.addNameSpaces(BaseXMLWriter.java:243)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.setupNamespaces(BaseXMLWriter.java:502)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:484)
>>>>          at
>>>>
>>>> com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:472)
>>>>          at
>>>> com.hp.hpl.jena.rdf.model.impl.ModelCom.write(ModelCom.java:320)
>>>>
>>>
>

Reply via email to