You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Crapo, Andrew (GE Research, US)" <cr...@ge.com> on 2020/08/06 15:23:43 UTC
Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
I have a small OWL file that imports other OWL files. I have saved each using RDFDataMgr with RDFFormat.RDF_THRIFT as the language. When I try to load one of the persisted OWL files using RDFDataMgr, I get this error: "org.apache.jena.riot.thrift.RiotThriftException: org.apache.thrift.protocol.TProtocolException: Required field 'uri' was not present". I experimented with making sure that there was a prefix and URI in the map for each OntModel that was written and determined that the error appears to occur for one of the imported models. However, I cannot get the RDF_THRIFT serialization to load. Any suggestions on how to get this to work?
Andrew W Crapo
Information Scientist
GE Global Research
T +1 518 387-5729
crapo@research.ge.com<ma...@research.ge.com>
One Research Circle
Niskayuna, NY 12302 USA
GE imagination at work
Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Posted by "Crapo, Andrew (GE Research, US)" <cr...@ge.com>.
Sorry, I missed this response and question somehow.
Here's the OWL model I'm using in RDF/XML format:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sadlbasemodel="http://sadl.org/sadlbasemodel"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:sadlimplicitmodel="http://sadl.org/sadlimplicitmodel"
xmlns:builtinfunctions="http://sadl.org/builtinfunctions"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:Simple="http://sadl.org/Simple.sadl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xml:base="http://sadl.org/Simple.sadl">
<owl:Ontology rdf:about="">
<owl:imports rdf:resource="builtinfunctions"/>
<owl:imports rdf:resource="sadlimplicitmodel"/>
<owl:imports rdf:resource="sadlbasemodel"/>
<rdfs:comment xml:lang="en">This ontology was created from a SADL file 'Simple.sadl' and should not be directly edited.</rdfs:comment>
</owl:Ontology>
<owl:Class rdf:ID="Rock"/>
</rdf:RDF>
This model is written out as RDF_THRIFT file Simple.trdf with this code:
model.setNsPrefix(prefix, modelName);
RDFDataMgr.write(out, model, format);
where
model is the Jena OntModel which serializes to RDF/XML as above,
prefix is "Simple",
modelName is "http://sadl.org/Simple.sadl",
out is the OutputStream,
format is RDFFormat.RDF-THRIFT
An attempt is then made to read this file with the following code:
schemaModel = ModelFactory.createOntologyModel(spec);
ReadFailureHandler rfHandler = new SadlReadFailureHandler(logger);
schemaModel.getDocumentManager().setProcessImports(true);
schemaModel.getDocumentManager().setReadFailureHandler(rfHandler );
schemaModel.getSpecification().setImportModelGetter((ModelGetter) configurationMgr.getModelGetter());
schemaModel.read(tbox, format);
where
spec is OntModelSpec.OWL_MEM
The ModelGetter set is a custom one but stepping down in to the code to where the exception is thrown, the ModelGetter is not called.
tbox is "file:/..../Simple.trdf"
format is "RDF-THRIFT"
Note that the imports were written similarly and the error occurs on reading in of this file, not reading the imports.
Again, the error is:
org.apache.jena.riot.thrift.RiotThriftException: org.apache.thrift.protocol.TProtocolException: Required field 'uri' was not present! Struct: RDF_PrefixDecl(prefix:
sadlbasemode, uri:null)
at org.apache.jena.riot.thrift.TRDF.exception(TRDF.java:133)
at org.apache.jena.riot.thrift.BinRDF.apply(BinRDF.java:180)
at org.apache.jena.riot.thrift.BinRDF.protocolToStream(BinRDF.java:159)
at org.apache.jena.riot.thrift.BinRDF.inputStreamToStream(BinRDF.java:147)
at org.apache.jena.riot.RDFParserRegistry$ReaderRDFThrift.read(RDFParserRegistry.java:216)
at org.apache.jena.riot.RDFParser.read(RDFParser.java:353)
at org.apache.jena.riot.RDFParser.parseNotUri(RDFParser.java:343)
at org.apache.jena.riot.RDFParser.parse(RDFParser.java:292)
at org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:540)
at org.apache.jena.riot.RDFDataMgr.parseFromInputStream(RDFDataMgr.java:901)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:299)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:285)
at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:69)
at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:305)
at org.apache.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2232)
at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:289)
at org.apache.jena.ontology.impl.OntModelImpl.readDelegate(OntModelImpl.java:3092)
at org.apache.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2190)
at org.apache.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2148)
Note also that this works for all of the other RDF serialization formats except RDF-THRIFT.
-----Original Message-----
From: Andy Seaborne <an...@apache.org>
Sent: Thursday, August 6, 2020 1:11 PM
To: users@jena.apache.org
Subject: EXT: Re: Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Hi there,
Could you provide the file that's in error together with what should be in the file? Files are processed one by one so the problem should show up when reading the thrift file in isolation to the ontology.
Which version of Jena are you using?
Andy
On 06/08/2020 16:23, Crapo, Andrew (GE Research, US) wrote:
> I have a small OWL file that imports other OWL files. I have saved each using RDFDataMgr with RDFFormat.RDF_THRIFT as the language. When I try to load one of the persisted OWL files using RDFDataMgr, I get this error: "org.apache.jena.riot.thrift.RiotThriftException: org.apache.thrift.protocol.TProtocolException: Required field 'uri' was not present". I experimented with making sure that there was a prefix and URI in the map for each OntModel that was written and determined that the error appears to occur for one of the imported models. However, I cannot get the RDF_THRIFT serialization to load. Any suggestions on how to get this to work?
>
> Andrew W Crapo
> Information Scientist
> GE Global Research
>
> T +1 518 387-5729
> crapo@research.ge.com<ma...@research.ge.com>
>
> One Research Circle
> Niskayuna, NY 12302 USA
>
> GE imagination at work
>
>
Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Posted by "Crapo, Andrew (GE Research, US)" <cr...@ge.com>.
Not sure if an attachment will work, but here's a ZIP of the RDF-THRIFT file that doesn't load.
-----Original Message-----
From: Andy Seaborne <an...@apache.org>
Sent: Thursday, August 6, 2020 1:11 PM
To: users@jena.apache.org
Subject: EXT: Re: Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Hi there,
Could you provide the file that's in error together with what should be in the file? Files are processed one by one so the problem should show up when reading the thrift file in isolation to the ontology.
Which version of Jena are you using?
Andy
On 06/08/2020 16:23, Crapo, Andrew (GE Research, US) wrote:
> I have a small OWL file that imports other OWL files. I have saved each using RDFDataMgr with RDFFormat.RDF_THRIFT as the language. When I try to load one of the persisted OWL files using RDFDataMgr, I get this error: "org.apache.jena.riot.thrift.RiotThriftException: org.apache.thrift.protocol.TProtocolException: Required field 'uri' was not present". I experimented with making sure that there was a prefix and URI in the map for each OntModel that was written and determined that the error appears to occur for one of the imported models. However, I cannot get the RDF_THRIFT serialization to load. Any suggestions on how to get this to work?
>
> Andrew W Crapo
> Information Scientist
> GE Global Research
>
> T +1 518 387-5729
> crapo@research.ge.com<ma...@research.ge.com>
>
> One Research Circle
> Niskayuna, NY 12302 USA
>
> GE imagination at work
>
>
Re: Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Posted by Andy Seaborne <an...@apache.org>.
Andrew,
When I write out that RDF data as Thrift, I get a shorter file.
Are you on MS Windows?
Two "\r" have become "\r\n" suggesting binary Thrift has been written to
a text output stream.
Andy
Test: read-write-read.
public static void main(String...a) throws IOException {
Model model = RDFDataMgr.loadModel("DATA.rdf");
try ( OutputStream out = new FileOutputStream("output.trdf") ) {
RDFDataMgr.write(out, model, RDFFormat.RDF_THRIFT);
}
Model model2 = RDFDataMgr.loadModel("output.trdf");
System.out.println("DONE");
System.exit(0);
}
On 11/08/2020 14:56, Crapo, Andrew (GE Research, US) wrote:
> Forgot to say, I'm using Jena 3.16.
>
> -----Original Message-----
> From: Andy Seaborne <an...@apache.org>
> Sent: Thursday, August 6, 2020 1:11 PM
> To: users@jena.apache.org
> Subject: EXT: Re: Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
>
> Hi there,
>
> Could you provide the file that's in error together with what should be in the file? Files are processed one by one so the problem should show up when reading the thrift file in isolation to the ontology.
>
> Which version of Jena are you using?
>
> Andy
>
>
> On 06/08/2020 16:23, Crapo, Andrew (GE Research, US) wrote:
>> I have a small OWL file that imports other OWL files. I have saved each using RDFDataMgr with RDFFormat.RDF_THRIFT as the language. When I try to load one of the persisted OWL files using RDFDataMgr, I get this error: "org.apache.jena.riot.thrift.RiotThriftException: org.apache.thrift.protocol.TProtocolException: Required field 'uri' was not present". I experimented with making sure that there was a prefix and URI in the map for each OntModel that was written and determined that the error appears to occur for one of the imported models. However, I cannot get the RDF_THRIFT serialization to load. Any suggestions on how to get this to work?
>>
>> Andrew W Crapo
>> Information Scientist
>> GE Global Research
>>
>> T +1 518 387-5729
>> crapo@research.ge.com<ma...@research.ge.com>
>>
>> One Research Circle
>> Niskayuna, NY 12302 USA
>>
>> GE imagination at work
>>
>>
Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Posted by "Crapo, Andrew (GE Research, US)" <cr...@ge.com>.
Forgot to say, I'm using Jena 3.16.
-----Original Message-----
From: Andy Seaborne <an...@apache.org>
Sent: Thursday, August 6, 2020 1:11 PM
To: users@jena.apache.org
Subject: EXT: Re: Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Hi there,
Could you provide the file that's in error together with what should be in the file? Files are processed one by one so the problem should show up when reading the thrift file in isolation to the ontology.
Which version of Jena are you using?
Andy
On 06/08/2020 16:23, Crapo, Andrew (GE Research, US) wrote:
> I have a small OWL file that imports other OWL files. I have saved each using RDFDataMgr with RDFFormat.RDF_THRIFT as the language. When I try to load one of the persisted OWL files using RDFDataMgr, I get this error: "org.apache.jena.riot.thrift.RiotThriftException: org.apache.thrift.protocol.TProtocolException: Required field 'uri' was not present". I experimented with making sure that there was a prefix and URI in the map for each OntModel that was written and determined that the error appears to occur for one of the imported models. However, I cannot get the RDF_THRIFT serialization to load. Any suggestions on how to get this to work?
>
> Andrew W Crapo
> Information Scientist
> GE Global Research
>
> T +1 518 387-5729
> crapo@research.ge.com<ma...@research.ge.com>
>
> One Research Circle
> Niskayuna, NY 12302 USA
>
> GE imagination at work
>
>
Re: Difficult using RDFFormat.RDF_THRIFT with RDFDataMgr
Posted by Andy Seaborne <an...@apache.org>.
Hi there,
Could you provide the file that's in error together with what should be
in the file? Files are processed one by one so the problem should show
up when reading the thrift file in isolation to the ontology.
Which version of Jena are you using?
Andy
On 06/08/2020 16:23, Crapo, Andrew (GE Research, US) wrote:
> I have a small OWL file that imports other OWL files. I have saved each using RDFDataMgr with RDFFormat.RDF_THRIFT as the language. When I try to load one of the persisted OWL files using RDFDataMgr, I get this error: "org.apache.jena.riot.thrift.RiotThriftException: org.apache.thrift.protocol.TProtocolException: Required field 'uri' was not present". I experimented with making sure that there was a prefix and URI in the map for each OntModel that was written and determined that the error appears to occur for one of the imported models. However, I cannot get the RDF_THRIFT serialization to load. Any suggestions on how to get this to work?
>
> Andrew W Crapo
> Information Scientist
> GE Global Research
>
> T +1 518 387-5729
> crapo@research.ge.com<ma...@research.ge.com>
>
> One Research Circle
> Niskayuna, NY 12302 USA
>
> GE imagination at work
>
>