JenaException:属性文件无效

发布于 2024-10-06 04:48:42 字数 942 浏览 6 评论 0原文

最初几周我和耶拿合作得很好。然而,今天 tomcat 开始出现错误。

我想我已经将范围缩小到:

Caused by: com.hp.hpl.jena.shared.JenaException: Invalid properties file
at com.hp.hpl.jena.util.Metadata.read(Metadata.java:71)
at com.hp.hpl.jena.util.Metadata.addMetadata(Metadata.java:41)
at com.hp.hpl.jena.util.Metadata.<init>(Metadata.java:35)
at com.hp.hpl.jena.JenaRuntime.<clinit>(JenaRuntime.java:25)

虽然,我无法弄清楚它意味着哪个属性文件。我从未为 jena 配置过属性文件。我能想到的唯一需要解析的东西是我的 web.xml,它看起来没有错误。

导致错误的代码为:

public void getOntModel()
{
    try
    {
        ssn = ModelFactory.createOntologyModel();
        ssn.read(NS);
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
        System.out.println("[ONTOLOGY] Failed to read ontology file");
    }
    System.out.println("[ONTOLOGY] Ontology successfully read");
}

具体为:

ssn = ModelFactory.createOntologyModel();

I have been working with Jena fine for the first few weeks. However, today tomcat has started spitting out errors.

I think I've narrowed it down to:

Caused by: com.hp.hpl.jena.shared.JenaException: Invalid properties file
at com.hp.hpl.jena.util.Metadata.read(Metadata.java:71)
at com.hp.hpl.jena.util.Metadata.addMetadata(Metadata.java:41)
at com.hp.hpl.jena.util.Metadata.<init>(Metadata.java:35)
at com.hp.hpl.jena.JenaRuntime.<clinit>(JenaRuntime.java:25)

Although, I can't figure out which properties file it means. I've never configured a property file for jena. The only other thing I can think of that requires parsing is my web.xml which doesn't look wrong.

The code that causes the error is:

public void getOntModel()
{
    try
    {
        ssn = ModelFactory.createOntologyModel();
        ssn.read(NS);
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
        System.out.println("[ONTOLOGY] Failed to read ontology file");
    }
    System.out.println("[ONTOLOGY] Ontology successfully read");
}

Specifically:

ssn = ModelFactory.createOntologyModel();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁许谁一生繁华 2024-10-13 04:48:42

查看源代码:

这就是正在发生的事情:

 private static String metadataLocation = "com/hp/hpl/jena/jena-properties.xml" ;
 private static Metadata metadata = new Metadata(metadataLocation) ;

它似乎正在尝试加载由metadataLocation指定的资源。你能检查一下你的类路径是否正确吗?特别是,检查是否有 Jena 库的混合版本 - 如果有,请重新排序它们,以便最新的位于类路径前面。

如果在某些类 Unix 系统上,您可以使用:

find /path/to/lib -name "*.jar"|while read fn; do
   echo ---- $fn
   jar tf $fn|grep jena-properties.xml
done

查找包含该属性文件的 jar - 只需将 /path/to/lib 更改为 Jena 库所在的路径。

Looking at the source:

This is what is happening:

 private static String metadataLocation = "com/hp/hpl/jena/jena-properties.xml" ;
 private static Metadata metadata = new Metadata(metadataLocation) ;

It seems that it's trying to load the resource specified by metadataLocation. Can you check that your classpath is correct? Especially, check that there are no mixed versions of Jena libraries - if there are, reorder them so the newest are in front of your classpath.

If on some Unix-like system, you can use:

find /path/to/lib -name "*.jar"|while read fn; do
   echo ---- $fn
   jar tf $fn|grep jena-properties.xml
done

to find the jar that contains that property file - just change /path/to/lib to the path where your Jena libraries are located.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文