Emilio,

TDBFactory.createDataset() creates an in-memory TDB backed dataset which is very useful for testing.

More inline:

On 24/05/13 14:42, Emilio Miguelanez wrote:
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

If that's OK, then I'm not clear what's going on without a test case (details seem to matter) Could you turn this into a standalone test case?

One immediate thing to try - could you put RIOT.init() as the first line of the program? I can't see how it would be missed but we're in the "details matter" zone.

For testing:

TDBDataset.createDataset() ;

is a faithful TDB system using a RAM-disk but otherwise is fully the same as using a disk DB. Very helpful for testing.


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

Return true.

And the string?



Does

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

work?

Yes, it works too.

So it's something to do with the imports but I can't see what it might be.


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

So, how can I translate into my original code?

No need - it's to replace FileManager in the test cases.


                 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.

Not in 2.10.0?  Useful to know.


And I am not using Windows either

Ack


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