Fuseki如何添加Pellet推理器

时间:2016-03-30 15:56:25

标签: java jena owl fuseki pellet

我想在我的Fuseki 2.3.1中使用pellet推理器

首先:我在我的config.ttl中添加了Pellet推理器:

ja:reasoner
        [ ja:reasonerClass
        "org.mindswap.pellet.jena.PelletReasonerFactory";]

所以现在我必须将Pellet的jar添加到fuseki

本页介绍如何将jar(不是特定的pellete)添加到fuseki

https://jena.apache.org/documentation/permissions/example.html

所以我知道这一行

  

exec $ JAVA $ JVM_ARGS -jar" $ JAR" " $ @"

我没有注意到这一行

  

java $ JVM_ARGS -cp" $ JAR:$ APPJAR" org.apache.jena.fuseki.cmd.FusekiCmd" $ @"

并取消注释以APPJAR=

开头的行

现在我仍然需要知道下载 Pellete的罐子,我发现这个链接https://datababel.wordpress.com/2013/06/26/fuseki-using-pellet-inference/说明哪些是罐子,

我从maven下载了最新的可用版本,其中包括:

粒料耶拿ignazio1977-2.4.0-ignazio1977.jar

粒料规则2.3.6-ansell.jar

粒料-EL-2.3.6-ansell.jar

粒料数据类型-2.3.6-ansell.jar

颗粒状芯ignazio1977-2.4.0-ignazio1977.jar

aterm-java的1.8.2-p1.jar

公地collections4-4.1-javadoc.jar

公地collections4-4.1.jar

我将它们添加到fuseki-server脚本中,如下所示:

APPJAR=pellet-jena-ignazio1977-2.4.0-ignazio1977.jar:pellet-rules-2.3.6-ansell.jar:pellet-el-2.3.6-ansell.jar:pellet-datatypes-2.3.6-ansell.jar:pellet-core-ignazio1977-2.4.0-ignazio1977.jar:aterm-java-1.8.2-p1.jar:commons-collections4-4.1-javadoc.jar:commons-collections4-4.1.jar

(它们位于fuseki的主目录中)

我运行./fuseki-server,我收到此错误

[2016-03-30 16:49:06] Server     INFO  Fuseki 2.3.1 2015-12-08T09:24:07+0000
[2016-03-30 16:49:07] Config     INFO  FUSEKI_HOME=/usr/local/apache-jena-fuseki-2.3.1
[2016-03-30 16:49:07] Config     INFO  FUSEKI_BASE=/usr/local/apache-jena-fuseki-2.3.1/run
[2016-03-30 16:49:07] Servlet    INFO  Initializing Shiro environment
[2016-03-30 16:49:07] Config     INFO  Shiro file: file:///usr/local/apache-jena-fuseki-2.3.1/run/shiro.ini
[2016-03-30 16:49:07] Config     INFO  Load configuration: file:///usr/local/apache-jena-fuseki-2.3.1/run/configuration/config.ttl
[2016-03-30 16:49:07] AssemblerHelp WARN  ja:loadClass: Migration to Jena3: Converting com.hp.hpl.jena.tdb.TDB to org.apache.jena.tdb.TDB
[2016-03-30 16:49:07] Server     ERROR Exception in initialization: com/hp/hpl/jena/reasoner/ReasonerFactory
Exception in thread "main" java.lang.NoClassDefFoundError: com/hp/hpl/jena/reasoner/ReasonerFactory
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.jena.assembler.assemblers.AssemblerBase.loadClass(AssemblerBase.java:109)
    at org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler.getReasonerFactoryByClassName(ReasonerFactoryAssembler.java:140)
    at org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler.getReasonerFactory(ReasonerFactoryAssembler.java:131)
    at org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler.open(ReasonerFactoryAssembler.java:50)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:117)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:81)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:39)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:35)
    at org.apache.jena.assembler.assemblers.InfModelAssembler.getReasonerFactory(InfModelAssembler.java:53)
    at org.apache.jena.assembler.assemblers.InfModelAssembler.getReasoner(InfModelAssembler.java:46)
    at org.apache.jena.assembler.assemblers.InfModelAssembler.openEmptyModel(InfModelAssembler.java:34)
    at org.apache.jena.assembler.assemblers.ModelAssembler.openModel(ModelAssembler.java:36)
    at org.apache.jena.assembler.assemblers.ModelAssembler.open(ModelAssembler.java:43)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:117)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:81)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:39)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:35)
    at org.apache.jena.assembler.assemblers.AssemblerGroup.openModel(AssemblerGroup.java:35)
    at org.apache.jena.sparql.core.assembler.DatasetAssembler.createDataset(DatasetAssembler.java:59)
    at org.apache.jena.sparql.core.assembler.DatasetAssembler.open(DatasetAssembler.java:43)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:117)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:81)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:39)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:35)
    at org.apache.jena.fuseki.build.Builder.buildDataService(Builder.java:75)
    at org.apache.jena.fuseki.build.Builder.buildDataAccessPoint(Builder.java:60)
    at org.apache.jena.fuseki.build.FusekiConfig.readConfiguration(FusekiConfig.java:249)
    at org.apache.jena.fuseki.build.FusekiConfig.readConfigurationDirectory(FusekiConfig.java:223)
    at org.apache.jena.fuseki.server.FusekiServer.initializeDataAccessPoints(FusekiServer.java:212)
    at org.apache.jena.fuseki.server.FusekiServerListener.init(FusekiServerListener.java:78)
    at org.apache.jena.fuseki.server.FusekiServerListener.contextInitialized(FusekiServerListener.java:46)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:835)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:530)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:808)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:342)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1368)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1335)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:511)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at org.eclipse.jetty.server.Server.start(Server.java:405)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart(Server.java:372)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.jena.fuseki.jetty.JettyFuseki.start(JettyFuseki.java:120)
    at org.apache.jena.fuseki.cmd.FusekiCmd$FusekiCmdInner.exec(FusekiCmd.java:359)
    at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
    at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
    at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
    at org.apache.jena.fuseki.cmd.FusekiCmd$FusekiCmdInner.innerMain(FusekiCmd.java:95)
    at org.apache.jena.fuseki.cmd.FusekiCmd.main(FusekiCmd.java:60)
Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.reasoner.ReasonerFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 71 more

请帮助

提示:我不知道我尝试的是不是正确的,我想要的是将Pellet推理器包含在fuseki中

更新

在ignazio告诉我我正在混合罐子之后,

我去了Pellet git hut并下载src并使用maven来编译并获取罐子

然后我将我正在使用的罐子改为:

commons-collections4-4.1-javadoc.jar:commons-collections4-4.1.jar:pellet-cli-2.4.0-SNAPSHOT.jar:jena-core-2.13.0.jar:pellet-jena-2.4.0-SNAPSHOT.jar:pellet-modularity-2.4.0-SNAPSHOT.jar:pellet-owlapi-2.4.0-SNAPSHOT.jar:pellet-pellint-2.4.0-SNAPSHOT.jar

但我得到了这个例外:

[2016-03-30 17:42:09] AssemblerHelp WARN  ja:loadClass: Migration to Jena3: Converting com.hp.hpl.jena.tdb.TDB to org.apache.jena.tdb.TDB
[2016-03-30 17:42:10] RDFDefaultErrorHandler WARN  unknown-source: {W136} Relative URIs are not permitted in RDF: specifically <ont-policy.rdf>
[2016-03-30 17:42:10] Server     ERROR Exception in initialization: expected class org.apache.jena.reasoner.ReasonerFactory, but had class org.mindswap.pellet.jena.PelletReasonerFactory
[2016-03-30 17:42:10] WebAppContext WARN  Failed startup of context o.e.j.w.WebAppContext@5bcde458{/,file:///usr/local/apache-jena-fuseki-2.3.1/webapp/,STARTING}
org.apache.jena.assembler.exceptions.NotExpectedTypeException: expected class org.apache.jena.reasoner.ReasonerFactory, but had class org.mindswap.pellet.jena.PelletReasonerFactory
  doing:
    root: 79f74f0ed3a21ef24b1cbccda7d37b62 with type: http://jena.hpl.hp.com/2005/11/Assembler#ReasonerFactory assembler class: class org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler
    root: file:///usr/local/apache-jena-fuseki-2.3.1/run/configuration/config.ttl#model_inf with type: http://jena.hpl.hp.com/2005/11/Assembler#InfModel assembler class: class org.apache.jena.assembler.assemblers.InfModelAssembler
    root: file:///usr/local/apache-jena-fuseki-2.3.1/run/configuration/config.ttl#dataset with type: http://jena.hpl.hp.com/2005/11/Assembler#RDFDataset assembler class: class org.apache.jena.sparql.core.assembler.DatasetAssembler

    at org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler.mustBeReasonerFactory(ReasonerFactoryAssembler.java:169)
    at org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler.getReasonerFactoryByClassName(ReasonerFactoryAssembler.java:141)
    at org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler.getReasonerFactory(ReasonerFactoryAssembler.java:131)
    at org.apache.jena.assembler.assemblers.ReasonerFactoryAssembler.open(ReasonerFactoryAssembler.java:50)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:117)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:81)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:39)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:35)
    at org.apache.jena.assembler.assemblers.InfModelAssembler.getReasonerFactory(InfModelAssembler.java:53)
    at org.apache.jena.assembler.assemblers.InfModelAssembler.getReasoner(InfModelAssembler.java:46)
    at org.apache.jena.assembler.assemblers.InfModelAssembler.openEmptyModel(InfModelAssembler.java:34)
    at org.apache.jena.assembler.assemblers.ModelAssembler.openModel(ModelAssembler.java:36)
    at org.apache.jena.assembler.assemblers.ModelAssembler.open(ModelAssembler.java:43)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:117)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:81)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:39)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:35)
    at org.apache.jena.assembler.assemblers.AssemblerGroup.openModel(AssemblerGroup.java:35)
    at org.apache.jena.sparql.core.assembler.DatasetAssembler.createDataset(DatasetAssembler.java:59)
    at org.apache.jena.sparql.core.assembler.DatasetAssembler.open(DatasetAssembler.java:43)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:117)
    at org.apache.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:81)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:39)
    at org.apache.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:35)
    at org.apache.jena.fuseki.build.Builder.buildDataService(Builder.java:75)
    at org.apache.jena.fuseki.build.Builder.buildDataAccessPoint(Builder.java:60)
    at org.apache.jena.fuseki.build.FusekiConfig.readConfiguration(FusekiConfig.java:249)
    at org.apache.jena.fuseki.build.FusekiConfig.readConfigurationDirectory(FusekiConfig.java:223)
    at org.apache.jena.fuseki.server.FusekiServer.initializeDataAccessPoints(FusekiServer.java:212)
    at org.apache.jena.fuseki.server.FusekiServerListener.init(FusekiServerListener.java:78)
    at org.apache.jena.fuseki.server.FusekiServerListener.contextInitialized(FusekiServerListener.java:46)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:835)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:530)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:808)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:342)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1368)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1335)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:511)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at org.eclipse.jetty.server.Server.start(Server.java:405)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart(Server.java:372)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.jena.fuseki.jetty.JettyFuseki.start(JettyFuseki.java:120)
    at org.apache.jena.fuseki.cmd.FusekiCmd$FusekiCmdInner.exec(FusekiCmd.java:359)
    at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
    at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
    at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
    at org.apache.jena.fuseki.cmd.FusekiCmd$FusekiCmdInner.innerMain(FusekiCmd.java:95)
    at org.apache.jena.fuseki.cmd.FusekiCmd.main(FusekiCmd.java:60)
[2016-03-30 17:42:10] Server     INFO  Started 2016/03/30 17:42:10 WEST on port 3030

2 个答案:

答案 0 :(得分:0)

您遇到的错误是

expected class org.apache.jena.reasoner.ReasonerFactory, but had class org.mindswap.pellet.jena.PelletReasonerFactory

我不是专家,但看起来Jena目前在你的类路径中的Pellet工厂与预期的类不匹配。

哪个版本的Jena附带Fuseki,Pellet目前使用哪个版本?

答案 1 :(得分:0)

解决方案: 请改用openllet。 只需在配置文件中更改为ja:reasonerClass "openllet.jena.PelletReasonerFactory",然后将openllet发行版和其他jar文件下载到类路径即可。

说明:错误

expected class org.apache.jena.reasoner.ReasonerFactory, but had class org.mindswap.pellet.jena.PelletReasonerFactory

是由于小球的org.mindswap.pellet.jena.PelletReasonerFactory实现了旧的接口(com.hp.hpl.jena.reasoner.ReasonerFactory),而该接口与Fuseki(org.apache.jena.reasoner.ReasonerFactory)中使用的接口不同。

openllet的openllet.jena.PelletReasonerFactory实现了正确的接口(org.apache.jena.reasoner.ReasonerFactory)。

检查其源代码:

openllet's PelletReasonerFactory.java

pellet's PelletReasonerFactory.java