3

We are using the RDF4J (formerly sesame) framework to run sparql queries to a remote GraphDB triple store.

This works successfully through the rdf4j HTTPRepository interface, which takes the Graphdb server's URL and the repository ID, but fails when using the rdf4j SPARQLRepository interface, which takes the sparlq endpoint url as parameter.

On running the query we get an exception on the query validation

"Failed to get server protocol; no such resource on this server: http:///sparql?sparql?queryLn=SPARQL&query=",

where http://<host:port>/sparql is what we think is the sparql endpoint's url. This is happening with both sesame 2.7.8 and rdf4j M3 libraries, and equally on two 'out of the box', i.e. started with the startup script, installations of graphdb free 6.6.2 and 7.0.3. It is also happening when attempting to connect via a rdf4j SPARQLRepository interface to the sparlq endpoint http://factforge.net/sparql, which we understand runs on graphdb.

We believe that the actual sparql endpoint's url might not be http:///sparql but something else which we could not find in the graphdb documentation. Appreciate any lights any one may shine on this.

EDIT: Code executed against Factforge's sparql endpoint:

    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();

The following exception is generated:

    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

Thank you for your help

2 Answers2

2

To access GraphDB SPARQL endpoint to your repository for example on your local machine, you can use following URL: http://localhost:7200/repositories/<#your_repository#>

You can read more on using the Sesame API with GraphDB here: http://graphdb.ontotext.com/documentation/free/using-graphdb-with-the-sesame-api.html

Venelin
  • 66
  • 1
1

I haven't pinpointed the root cause, however, I have noticed that the problem occurs in RDF4J 2.0M3, but no longer in 2.0 final (or 2.0.1, the latest release). There are two likely issues that have been fixed since then, namely a version bump of the Apache HttpComponents libraries used by RDF4J (#267), as well as an improvement in how the RDF4J client composes its HTTP Accept header (#228).

TL;DR: upgrade to RDF4J 2.0.1 and your problem should disappear.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
  • From my tests it actually appears to be a combination of both the rdf4j framework AND something to do with settings in the GraphDB repository: 1- I can now execute the simple code above with rdf4j 2.0.1 (but 2.0 is also OK). – Riccardo Santoro Sep 15 '16 at 15:23
  • 1- I got an e-mail from DBGraph support indicating that they were checking some 'configuration setting at factforge'. 2- I got it working with factforge but only with RDF4j versions 2.0 or 2.0.1. 3-Even with rdf4j version 2.0 or 2.0.1 I cannot connnect to my local GraphDB repository. 4- On the older rdf4j version and even sesame 4.0 I could connect to a Virtuoso store. – Riccardo Santoro Sep 15 '16 at 15:34
  • It appears therefore that you need BOTH some setting to be right in the GraphDB repo AND rdf4j version 2.0 or above. I asked GraphDB support to share whatever configuration setting they did that seems to have solved the problem on factforge. If they answer here it would be great, if they answer me I'll post it here. THANKS A LOT for your help – Riccardo Santoro Sep 15 '16 at 15:35