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