eclipse-rdf4j / rdf4j

Eclipse RDF4J: scalable RDF for Java
https://rdf4j.org/
BSD 3-Clause "New" or "Revised" License
367 stars 164 forks source link

FedX: Federation tutorial sample returns DBPedia HTTP error 406 #3866

Open zify85 opened 2 years ago

zify85 commented 2 years ago

Current Behavior

While setting up RDF4J Server I tested the federation capability using the sample located in the documentation at https://rdf4j.org/documentation/programming/federation/#using-a-java-program

Instead of using Java, I used the workbench and setup individual SparlQL Endpoint Proxies repositories for DBPedia and Wikidata per the example. I then created a federated respository using the two repos.

When I run the following query I received an error:

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

SELECT * WHERE {
  ?country a <http://dbpedia.org/class/yago/WikicatMemberStatesOfTheEuropeanUnion> .
  ?country <http://www.w3.org/2002/07/owl#sameAs> ?countrySameAs .
  ?countrySameAs wdt:P2131 ?gdp .
}

Error

Query evaluation error: org.eclipse.rdf4j.federated.exception.OptimizationException: Error checking results for endpoint DBPedia: @ DBPedia - HTTP Error: 406 Not Acceptable. Subquery: ASK { ?country <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/class/yago/WikicatMemberStatesOfTheEuropeanUnion> . }

NOTE: I can run queries successfully against DBPedia or Wikidata using the individual repos but the federated endpoint does not work.

Expected Behavior

I expected the federated repository to work using the sample listed in the documentation https://rdf4j.org/documentation/programming/federation/#using-a-java-program

I attempted to repeat the Java code sample using the workbench.

Steps To Reproduce

  1. install rdf4j server 4.0.0 and workbench on an AWS EC2 instance with outbound security rule set to 0.0.0.0
  2. In RDF4J workbench, create a Sparql Proxy Endpoint repository for DBPedia and another one for Wikidata (http://dbpedia.org/sparql and https://query.wikidata.org/sparql)
  3. In RDF4J Workbench, create a federated repository and select the DBPedia and Wikidata repositories
  4. Run query `PREFIX wd: http://www.wikidata.org/entity/ PREFIX wdt: http://www.wikidata.org/prop/direct/

SELECT * WHERE { ?country a http://dbpedia.org/class/yago/WikicatMemberStatesOfTheEuropeanUnion . ?country http://www.w3.org/2002/07/owl#sameAs ?countrySameAs . ?countrySameAs wdt:P2131 ?gdp . }`

  1. Receive error Query evaluation error: org.eclipse.rdf4j.federated.exception.OptimizationException: Error checking results for endpoint DBPedia: @ DBPedia - HTTP Error: 406 Not Acceptable. Subquery: ASK { ?country <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/class/yago/WikicatMemberStatesOfTheEuropeanUnion> . }

Version

4.0.0

Are you interested in contributing a solution yourself?

Perhaps?

Anything else?

No response

patrickwyler commented 2 years ago

Hi @howellzify I faced a similar issue and found out it's related to this issue from Virtuoso. I think you need to turn of ASK queries for this endpoints.

<http://DBpedia> a sd:Service ;
    fedx:store "SPARQLEndpoint";
    sd:endpoint "http://dbpedia.org/sparql";
    fedx:supportsASKQueries false .

https://rdf4j.org/documentation/programming/federation/

abrokenjester commented 2 years ago

Thanks for supplying a pointer to the solution @patrickwyler !

mhoangvslev commented 1 year ago

In the same link, they also posted a workaround. Could you please look into that and update the code?

abrokenjester commented 1 year ago

In the same link, they also posted a workaround. Could you please look into that and update the code?

I'm not sure what you're asking. The bug is on Virtuoso's side as it returns text/html on ASK queries. I don't think there's anything we can do on our end to make this work. Or did I overlook something?

mhoangvslev commented 1 year ago

I would like to draw your attention to the last two comments and this code snippet given as a workaround:

SPARQLRepository repo = new SPARQLRepository(host);
Map<String, String> headers =new HashMap<>();
headers.put("Accept", "application/sparql-results+json");
repo.setAdditionalHttpHeaders(headers);

Is this possible to integrate this into FedX?

abrokenjester commented 1 year ago

Not sure, but we can take another look! Reopened.