在Jena 2.10.1中无法使用FileManager加载资源 [英] Loading resources with FileManager doesn't work in Jena 2.10.1

查看:69
本文介绍了在Jena 2.10.1中无法使用FileManager加载资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在Jena 2.10.0中有效,但在Jena 2.10.1中失败:

The following code works in Jena 2.10.0 but fails in Jena 2.10.1:

model = FileManager.get().loadModel(uri, base, "RDF/XML");

堆栈跟踪为:

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), 
...

根据我的调试,在ParserTurtle类的初始化中的某个静态块中有一个NPE.但是,确切的位置不会出现在堆栈跟踪中,而且我无法通过自己初始化此类来重现它.

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.

一个修复程序是最好的,但是对于在Jena 2.10.1中如何使用FileManager的任何提示,我将不胜感激.我需要FileManager来加载location-mapping.n3文件.

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.

自拍

这与 https://stackoverflow.com/questions/16196069/jena-filemanager-readmodel-cannot-查找文件(我会对此发表评论,但我的信誉不高)

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)

推荐答案

我通过加载IRI而不是URI来解决了这个问题.以下示例:

I solved it by loading an IRI instead of an URI. Examples below:

IRI iri = IRI.create(this.getClass().getResource("/dataset_rdf.owl"));
Model model = FileManager.get().loadModel(iri.getFragment());

使用此Maven依赖项:

using this maven dependency:

<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-apibinding -->
        <dependency>
            <groupId>net.sourceforge.owlapi</groupId>
            <artifactId>owlapi-apibinding</artifactId>
            <version>3.4</version>
        </dependency>

我希望对您有帮助

这篇关于在Jena 2.10.1中无法使用FileManager加载资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆