首页 文章

GraphDB sparql endpoints 通过sesame / rdf4j SPARQLRepository接口不可用

提问于
浏览
3

我们使用RDF4J(以前称为sesame)框架来运行sparql查询到远程GraphDB三元组商店 .

这通过rdf4j HTTPRepository接口成功运行,该接口接受Graphdb服务器的URL和存储库ID,但在使用rdf4j SPARQLRepository接口时失败,该接口将sparlq endpoints url作为参数 .

在运行查询时,我们在查询验证上获得异常

“无法获得服务器协议;此服务器上没有此类资源:http:/// sparql?sparql?queryLn = SPARQL&query =”,

其中 http://<host:port>/sparql 就是我们认为的sparql endpoints 's url. This is happening with both sesame 2.7.8 and rdf4j M3 libraries, and equally on two '开箱即用',即以启动脚本开始,安装了graphdb free 6.6.2和7.0.3 . 当尝试通过rdf4j SPARQLRepository接口连接到sparlq endpoints http://factforge.net/sparql时也会发生这种情况,我们理解在graphdb上运行它 .

我们认为实际的sparql endpoints 的url可能不是http:/// sparql,而是我们在graphdb文档中找不到的其他东西 . 欣赏任何人可能会发光的任何灯光 .

EDIT: 针对Factforge的sparql endpoints 执行的代码:

final String endPoint = "http://factforge.net/sparql";
    final String query = "Select distinct ?airport where {?airport a dbp-ont:Airport} LIMIT 2";

    SPARQLRepository repository = new SPARQLRepository(endPoint,endPoint);
    repository.initialize();
    RepositoryConnection connection = repository.getConnection();
    TupleQueryResult result = connection.prepareTupleQuery(QueryLanguage.SPARQL,query)
                                        .evaluate();

生成以下异常:

Caused by: org.eclipse.rdf4j.repository.RepositoryException: Failed to    get server protocol; no such resource on this server: http://factforge.net/sparql?queryLn=SPARQL&query=Select+distinct+%3Fairport+where+%7B%3Fairport+a+dbp-ont%3AAirport%7D+LIMIT+2&infer=true
at org.eclipse.rdf4j.http.client.SparqlSession.executeOK(SparqlSession.java:1023)
at org.eclipse.rdf4j.http.client.SparqlSession.sendTupleQueryViaHttp(SparqlSession.java:787)
at org.eclipse.rdf4j.http.client.SparqlSession.getBackgroundTupleQueryResult(SparqlSession.java:684)
at org.eclipse.rdf4j.http.client.SparqlSession.sendTupleQuery(SparqlSession.java:341)
at org.eclipse.rdf4j.repository.sparql.query.SPARQLTupleQuery.evaluate(SPARQLTupleQuery.java:43)
... 1 more

谢谢您的帮助

2 回答

  • 1

    我没有确定根本原因,但是,我注意到问题出现在RDF4J 2.0M3中,但不再出现在2.0 final(或2.0.1,最新版本)中 . 从那时起,有两个可能已经修复的问题,即RDF4J(#267)使用的Apache HttpComponents库的版本颠簸,以及RDF4J客户端如何组成其HTTP Accept头(#228)的改进 .

    TL; DR:升级到RDF4J 2.0.1,您的问题应该消失 .

  • 1

    要在您的本地计算机上访问GraphDB SPARQL endpoints 到您的存储库,您可以使用以下URL:http://localhost:7200/repositories/ <#your_repository#>

    您可以在此处阅读有关使用带有GraphDB的Sesame API的更多信息:http://graphdb.ontotext.com/documentation/free/using-graphdb-with-the-sesame-api.html

相关问题