尽管有很多问题,但我仍然无法配置Apache Jena Fuseki ...
我正在尝试配置一个激活了TDB和OWL推理程序的Apache Jena Fuseki实例,以测试我的应用程序。我需要创建一个数据集,执行测试,然后以编程方式删除该数据集。
我使用stain/jena-fuseki
码头工人镜像来运行Apache Jena Fuseki。
我在3.10.0版中运行Jena Fuseki。
bash-4.3# ./fuseki-server -version
Jena: VERSION: 3.10.0
Jena: BUILD_DATE: 2018-12-30T15:45:57+0000
TDB: VERSION: 3.10.0
TDB: BUILD_DATE: 2018-12-30T15:45:57+0000
Fuseki: VERSION: 3.10.0
Fuseki: BUILD_DATE: 2018-12-30T15:45:57+0000
我使用以下shiro.ini
文件。
我允许所有人访问,这只是一个测试实例。
bash-4.3# cat /fuseki/shiro.ini
[main]
# Development
ssl.enabled = false
plainMatcher=org.apache.shiro.authc.credential.SimpleCredentialsMatcher
iniRealm.credentialsMatcher = $plainMatcher
[users]
admin=mysupersecurepassword
[roles]
[urls]
## Control functions open to anyone
/$/status = anon
/$/ping = anon
# Everything else
/**=anon
我使用默认的config.ttl
文件:
bash-4.3# cat /fuseki/config.ttl
# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
## Fuseki Server configuration file.
@prefix : <#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] rdf:type fuseki:Server ;
.
为了测试我的应用程序,我试图创建一个数据集,执行测试,并以编程方式删除该数据集。为此,我使用Fuseki HTTP Administration Protocol。
我按照以下步骤操作:
POST /$/datasets
创建数据集。POST /dataset_name/data
上传数据文件。POST /dataset_name?update=DROP+ALL
删除数据。DELETE /$/datasets/dataset_name
删除数据集。使用curl:
curl -F 'files[]=@dataset.ttl' http://localhost:3030/$/datasets
我使用以下dataset.ttl
文件:
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix : <#> .
# Custom code
tdb:GraphTDB rdfs:subClassOf ja:Model .
# Setup service
:service rdf:type fuseki:Service ;
rdfs:label "TDB dataset_name" ;
fuseki:name "dataset_name" ;
fuseki:dataset :dataset ;
fuseki:serviceQuery "query", "sparql" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadGraphStore "get" ;
.
# Setup Assembler model with reasoner
:dataset rdf:type ja:RDFDataset;
ja:defaultGraph :modelInf ;
.
:modelInf rdf:type ja:InfModel;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
] ;
.
# TDB dataset used for RDF storage
:tdbGraph rdf:type tdb:GraphTDB;
tdb:location "/fuseki/databases/dataset_name" ;
.
Jena Fuseki日志
[2019-10-23 14:41:00] Admin INFO [6] POST http://localhost:3030/$/datasets
[2019-10-23 14:41:00] Admin INFO [6] Filename: dataset.ttl, Content-Type=application/octet-stream, Charset=null => Turtle : Count=19 Triples=19 Quads=0
[2019-10-23 14:41:00] Admin INFO [6] Create database : name = /dataset_name
[2019-10-23 14:41:02] Admin INFO [6] 200 OK (1.894 s)
一切都很好:P
使用curl:
curl -F 'files[]=@data.rdf' http://localhost:3030/dataset_name/data
{
"count" : 1524 ,
"tripleCount" : 1524 ,
"quadCount" : 0
}
Jena Fuseki日志
[2019-10-23 14:44:52] Fuseki INFO [7] POST http://localhost:3030/dataset_name/data
[2019-10-23 14:44:53] Fuseki INFO [7] Filename: data.rdf, Content-Type=application/octet-stream, Charset=null => RDF/XML : Count=1524 Triples=1524 Quads=0
[2019-10-23 14:44:54] Fuseki INFO [7] 200 OK (1.858 s)
一切都很好:P
测试我的应用程序(此处无用)
使用curl:
curl -d "update=DROP+ALL" -X POST http://localhost:3030/dataset_name/update
...
Update succeeded
...
Jena Fuseki日志
[2019-10-23 15:04:13] Fuseki INFO [67] POST http://localhost:3030/dataset_name/update
[2019-10-23 15:04:14] Fuseki INFO [67] 200 OK (268 ms)
一切都很好:P
使用curl:
curl -X DELETE http://localhost:3030/$/datasets/dataset_name
Jena Fuseki日志
[2019-10-23 15:10:17] Admin INFO [92] DELETE http://localhost:3030/$/datasets/dataset_name
[2019-10-23 15:10:17] Admin INFO [92] DELETE ds=/dataset_name
[2019-10-23 15:10:17] Server INFO Shutting down data service for [, data, upload, query, get, update, sparql]
[2019-10-23 15:10:17] Admin WARN [92] RC = 500 : Not in a transaction
org.apache.jena.tdb.transaction.TDBTransactionException: Not in a transaction
at org.apache.jena.tdb.transaction.DatasetGraphTransaction.get(DatasetGraphTransaction.java:140)
at org.apache.jena.tdb.transaction.DatasetGraphTransaction.getDatasetGraphToQuery(DatasetGraphTransaction.java:86)
at org.apache.jena.tdb.store.GraphTxnTDB.getDatasetGraphTDB(GraphTxnTDB.java:51)
at org.apache.jena.tdb.store.GraphTDB.sync(GraphTDB.java:128)
at org.apache.jena.tdb.store.GraphTDB.close(GraphTDB.java:133)
at org.apache.jena.reasoner.BaseInfGraph.close(BaseInfGraph.java:445)
at org.apache.jena.reasoner.rulesys.BasicForwardRuleInfGraph.close(BasicForwardRuleInfGraph.java:360)
at org.apache.jena.reasoner.rulesys.FBRuleInfGraph.close(FBRuleInfGraph.java:710)
at org.apache.jena.sparql.core.DatasetGraphMapLink.close(DatasetGraphMapLink.java:199)
at org.apache.jena.fuseki.server.DataService.expel(DataService.java:223)
at org.apache.jena.fuseki.server.DataService.shutdown(DataService.java:199)
at org.apache.jena.fuseki.mgt.ActionDatasets.execDeleteItem(ActionDatasets.java:360)
at org.apache.jena.fuseki.ctl.ActionContainerItem.execDelete(ActionContainerItem.java:105)
at org.apache.jena.fuseki.ctl.ActionContainerItem.perform(ActionContainerItem.java:64)
at org.apache.jena.fuseki.ctl.ActionCtl.executeLifecycle(ActionCtl.java:68)
at org.apache.jena.fuseki.ctl.ActionCtl.executeAction(ActionCtl.java:62)
at org.apache.jena.fuseki.ctl.ActionCtl.execCommonWorker(ActionCtl.java:53)
at org.apache.jena.fuseki.servlets.ActionBase.doCommon(ActionBase.java:74)
at org.apache.jena.fuseki.ctl.ActionContainerItem.doDelete(ActionContainerItem.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
at org.apache.jena.fuseki.servlets.FusekiFilter.doFilter(FusekiFilter.java:101)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
at org.apache.jena.fuseki.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:285)
at org.apache.jena.fuseki.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:248)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:690)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:503)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:745)
[2019-10-23 15:10:17] Admin INFO [92] 500 Not in a transaction (65 ms)
这是问题所在。任何人都可以帮助解决这个问题?
我尝试使用默认数据集配置文件执行相同的步骤,但未收到任何错误。因此,我假设这来自数据集配置文件。
这就是我所谓的默认数据集配置文件:
@prefix : <http://base/#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix tdb2: <http://jena.apache.org/2016/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
:service_tdb_all a fuseki:Service ;
rdfs:label "TDB2 dataset_name" ;
fuseki:dataset :tdb_dataset_readwrite ;
fuseki:name "dataset_name" ;
fuseki:serviceQuery "query" , "sparql" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" .
:tdb_dataset_readwrite a tdb2:DatasetTDB2 ;
tdb2:location "/fuseki/databases/dataset_name" .
我找不到任何有关如何正确配置Jena Fuseki的文档。可以找到很多示例,但可以追溯到几年以前,不知道它们是否仍是最新的。而且没有解释它们的真正工作原理,因此很难适应特定情况。
如果有任何解释什么是“ ja:RDFDataset”,“ ja:InfModel”和其他“ ja:things”以及它们如何工作的文档/教程,将不胜感激。
我仍然从本体/三元组/链接数据开始,而那些文档并不是最容易阅读的:
我尝试了不同的配置示例,但总是在步骤1或5出现错误。
示例
配置:
@prefix : <#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] rdf:type fuseki:Server ;
fuseki:services (
<#service>
) .
## ---------------------------------------------------------------
## Service with only SPARQL query on an inference model.
## Inference model base data in TDB.
<#service> rdf:type fuseki:Service ;
fuseki:name "dataset_name" ;
fuseki:serviceQuery "query" , "sparql" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:dataset <#dataset> ;
.
<#dataset> rdf:type ja:RDFDataset ;
ja:defaultGraph <#model> ;
.
<#model> rdf:type ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner> ;
] ;
.
<#tdbGraph> rdf:type tdb:GraphTDB ;
tdb:dataset <#tdbDataset> ;
.
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "/fuseki/databases/dataset_name" ;
.
第1步出错。
Fuseki日志:
[2019-10-23 15:20:51] Admin INFO [93] POST http://localhost:3030/$/datasets
[2019-10-23 15:20:51] Admin INFO [93] Filename: dataset.ttl, Content-Type=text/turtle, Charset=null => Turtle : Count=23 Triples=23 Quads=0
[2019-10-23 15:20:51] Admin INFO [93] Create database : name = /dataset_name
[2019-10-23 15:20:51] Admin WARN [93] RC = 500 : cannot find a most specific type for :tdbGraph, which has as possibilities: ja:Model tdb:GraphTDB.
org.apache.jena.assembler.exceptions.AmbiguousSpecificTypeException: cannot find a most specific type for :tdbGraph, which has as possibilities: ja:Model tdb:GraphTDB.
答案 0 :(得分:0)
完整服务器提供使用模板之一通过UI或协议创建的数据库的删除。推送到服务器的任意配置文件无法通过这种方式删除;即使可以将它们从服务器取消链接,也可能会留下一些东西(它们是任意的assmbler文件),这不利于测试。
对于测试,有一种更简单的方法。为每个测试启动服务器,无论是脚本编写的还是Java编写的(JUnit等)。。服务器的“ Fuseki main”版本可以非常快速地启动和停止。因此,以所需的配置启动服务器-如果数据相当小,则可以使用内存中的TDB数据库(位置为“ --mem--”)存储数据。
这将在服务器退出时完成清理,使测试完全隔离。