Reputation: 31
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
Upvotes: 3
Views: 2080
Reputation: 66
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
Upvotes: 2
Reputation: 22052
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.
Upvotes: 1