问题
The following code works in Jena 2.10.0 but fails in Jena 2.10.1:
model = FileManager.get().loadModel(uri, base, "RDF/XML");
The stack trace is:
com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:67),
com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:33),
com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:116),
com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:81),
com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:274),
com.hp.hpl.jena.util.LocationMapper.initFromPath(LocationMapper.java:158),
com.hp.hpl.jena.util.LocationMapper.get(LocationMapper.java:71),
com.hp.hpl.jena.util.FileManager.makeGlobal(FileManager.java:122),
com.hp.hpl.jena.util.FileManager.get(FileManager.java:88),
...
From what I can debug, there is a NPE in the initialization of the ParserTurtle class, in some static block. However the exact location does not appear in the stack trace and I can't reproduce it by initializing this class myself.
A fix would be best, but I'd be grateful for any hint on how I can use FileManager in Jena 2.10.1. I need FileManager to load the location-mapping.n3 file.
Piotr
This is related to https://stackoverflow.com/questions/16196069/jena-filemanager-readmodel-cannot-find-file (I'd comment on it but I don't have enough reputation)
回答1:
After further debugging it turned out that the actual code that worked in 2.10.0 but not in 2.10.1 was related to initializing the LocationMapper, see http://issues.apache.org/jira/browse/JENA-505. There I attached a minimal example that demonstrates the problem.
The actual error is only signalled by a warning message:
2013.08.09 14:21:00 [main] LocationMapper WARN: Error in configuration file: null
but if you try to later load a file that was mapped in the location mapper, you are likely to a get an error similar to
com.hp.hpl.jena.shared.NotFoundException: Not found: (...)
which is why I related this issue to 16196069.
来源:https://stackoverflow.com/questions/18144131/loading-resources-with-filemanager-doesnt-work-in-jena-2-10-1