Hi Andy,

> Hi Emilio,
> 
> Plain new FileManager() is going to return an FileManager object with no 
> handlers. FileManager.get() is the standard configured one.  Could you try 
> that please?

I have tried and it works

> What does f.getAbsolutePath() return?  There may be drive letter confusion 
> going on.

Return true.

> 
> Does
> 
> String fn = "/Users/emiguelanez/sb.work/sb.dev/onto-db/ont-seed/target.owl" ;
> RDFDataMgr.readModel(bModel, fn) ;
> 
> work?

Yes, it works too.

> RDFDataMgr.readModel is newer preferred style - it's using the same machinary 
> as FileManager.

So, how can I translate into my original code?

                Dataset ds = TDBFactory.createDataset(repoDir) ;
                Model bModel = ds.getDefaultModel();
                OntModel aModel = ModelFactory.createOntologyModel(spec, 
bModel);

FYI, I have tested this code with all previous version of apache-jena and it 
works. It only fails in the latest one.

And I am not using Windows either

Cheers,

Emilio

>       Andy (not a Windows user)
> 
> On 24/05/13 13:08, Emilio Miguelanez wrote:
>> Hello all,
>> 
>> 
>> I have some issues reading from a local file.
>> The details are as follows:
>> 
>> 
>> — Using latest version: apache-jena-2.10.1
>> — Main owl file imports local file, as follows
>> 
>>   <owl:Ontology rdf:about="">
>>     <owl:imports 
>> rdf:resource="file:///Users/emiguelanez/sb.work/sb.dev/onto-db/ont-seed/target.owl"/>
>>   </owl:Ontology
>> 
>> 
>> — TDB is creating using ./tdbloader2, loading main owl file
>> — In the application, the following code fails
>> 
>> 
>>                 Dataset ds = TDBFactory.createDataset(repoDir) ;
>>                 Model bModel = ds.getDefaultModel();
>>                 OntModel aModel = ModelFactory.createOntologyModel(spec, 
>> bModel);
>> 
>> given the following exception, triggered at the creation of the OntModel
>> 
>> [com.hp.hpl.jena.ontology.OntDocumentManager] :: An error occurred while 
>> attempting to read from 
>> file:///Users/emiguelanez/sb.work/sb.dev/onto-db/ont-seed/target.owl. Msg 
>> was 'Not found: 
>> file:///Users/emiguelanez/sb.work/sb.dev/onto-db/ont-seed/target.owl'.
>> com.hp.hpl.jena.shared.NotFoundException: Not found: 
>> file:///Users/emiguelanez/sb.work/sb.dev/onto-db/ont-seed/target.owl
>>      at 
>> com.hp.hpl.jena.util.FileManager.readModelWorker(FileManager.java:399)
>>      at com.hp.hpl.jena.util.FileManager.readModel(FileManager.java:345)
>>      at com.hp.hpl.jena.util.FileManager.readModel(FileManager.java:329)
>>      at 
>> com.hp.hpl.jena.ontology.OntDocumentManager.read(OntDocumentManager.java:1061)
>> 
>> — I have done two tests:
>> 
>> ++ Test 1: run the following code
>> 
>>             File f = new 
>> File("/Users/emiguelanez/sb.work/sb.dev/onto-db/ont-seed/target.owl");
>>                 logger.info(f.exists()); // prints "true"
>>                 new FileManager().readModel(bModel, f.getAbsolutePath());
>>                 logger.info("Done");
>> 
>> and fails
>> 
>> ++ Test 2: run the following code
>> 
>>              File f = new 
>> File("/Users/emiguelanez/sb.work/sb.dev/onto-db/ont-seed/target.owl");
>>                 logger.info(f.exists()); // prints "true"
>>                 bModel.read(new FileInputStream(f),"");
>>                 logger.info("Done");
>> 
>> and succeed.
>> 
>> 
>> I could include the code from the second test into the application, but I 
>> don't want to include file directories into the code.
>> 
>> Any ideas what is happening?
>> 
>> Cheers,
>> Emilio
>> 
>> --
>> Emilio Migueláñez Martín
>> [email protected]
>> 
>> 
>> 
> 

--
Emilio Migueláñez Martín
[email protected]


Reply via email to