0

I have a problem with a Federated Query. It is used only as an example for my project.

I retrieve all Wikimedia Categories via DBpedia SPARQL Endpoint in Wikidata, but thats not the problem as the query below works in Wikidata.

But when I want to run it on Apache Jena Query, it throws an HttpException 404. Why?

Query:

prefix bd: <http://www.bigdata.com/rdf#>
prefix dbc: <http://dbpedia.org/resource/Category:>
prefix dct: <http://purl.org/dc/terms/>
prefix wikibase: <http://wikiba.se/ontology#>
SELECT ?objectLabel WHERE {
SERVICE <http://dbpedia.org/sparql> {
       ?subject dct:subject dbc:Countries_in_Asia ; owl:sameAs ?object
       FILTER (STRSTARTS(STR(?object), "http://www.wikidata.org")) 
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

Java Code:

public static ResultSet executeQuery(String queryString, String service) {
    Query query = QueryFactory.create(queryString);
    QueryEngineHTTP queryEngine = QueryExecutionFactory.createServiceRequest(service, query);
    ResultSet resultSet = queryEngine.execSelect();
    return resultSet;
}

Service = SPARQL Endpoint Service which I use https://query.wikidata.org/sparql

Exception Trace in Apache Jena:

HttpException: 404
at org.apache.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:325)
at org.apache.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:282)
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:342)
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:334)
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
grajkowski
  • 349
  • 1
  • 3
  • 14

1 Answers1

2

404 is returned by the remote server. wikibase:label is not a real SPARQL endpoint. You can not use it in a SERVICE clause if this is being executed locally with remote calls via SERVICE.

AndyS
  • 16,345
  • 17
  • 21
  • A right, the "magic" label service. I'm wondering how any federated query engine could ever execute this SPARQ? The standard semantics is bottom-up, right? Thus, data from both SERVICE clauses would be retrieved and joined locally. Even smarter engines couldn't do anything like push-through I guess because there is no variable overlap. – UninformedUser Aug 04 '17 at 01:17
  • On the other hand, indeed it works if you use Wikidata as the remote endpoint in Jena. – UninformedUser Aug 04 '17 at 01:19
  • Okay i removed the SERVICE clause, but it still remains a HttpException 404... Query still works in the Wikidata SPARQL Endpoint. – grajkowski Aug 04 '17 at 10:36
  • For me it works even with the SERVICE clause: `rsparql --service=https://query.wikidata.org/sparql --query /tmp/query.txt` where `query.txt` contains your original query. – UninformedUser Aug 04 '17 at 11:03
  • And it works also with your code, I tried with Apache Jena 3.3.0 - note, you're missing the `owl:` prefix declaration and the code should return with an exception, thus, you're not showing the whole code or a different query. – UninformedUser Aug 04 '17 at 11:49
  • 404 might be returned because of Wikidata endpoint was down. Or maybe the DBpedia endpoint, I don't know how Wikidata (resp. the Blazegraph backend) handles unaccessible SERVICE URLs. – UninformedUser Aug 04 '17 at 11:52