Hi Konrad
I'm not a heavy Jena user myself so can't say whether it is specifically
Jena that causes this error but I do use the Talis platform quite a bit and
I think I see what your problem might be:
> if(graph!=null) {queryExecution.addDefaultGraph(graph);}
This line of your code is adding a default graph to the query request. The
problem is that the Talis platform is a pure Triple store (i.e. it has no
notion of named graphs) so it does not support setting the default graph.
I checked this in the browser and adding the default-graph-uri querysting
parameter - which I assume it what addDefaultGraph() has the effect of
doing to the HTTP request to the remote endpoint - causes the endpoint to
return an error rather than a query result.
So try commenting out this line and then your query should then hopefully
work fine
Rob
On Mon, 13 Jun 2011 13:04:33 +0200, Konrad Höffner
<[email protected]> wrote:
> Dear Jena Users,
>
> When I manually query the endpoint
> http://api.talis.com/stores/airports/services/sparql with the following
> query, the following, for me seemingly totally valid, XML is returned.
> With Jena however, I always get an http exception. How can I fix this
> problem?
>
> The query:
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> select * where
> {
> ?entity rdfs:label ?name.
> filter
> (
> ?entity = <http://airports.dataincubator.org/airports/NGUK>
> ||?entity = <http://airports.dataincubator.org/airports/TQPF>
> ||?entity = <http://airports.dataincubator.org/airports/SEAM>
> ||?entity = <http://airports.dataincubator.org/airports/ID-AHI>
> ||?entity = <http://airports.dataincubator.org/airports/OIZB>
> )
> }
>
> (whitespaces and newlines inserted for readability)
>
> The resulting xml:
>
> <?xml version="1.0"?>
> <sparql xmlns="http://www.w3.org/2005/sparql-results#">
> <head>
> <variable name="entity"/>
> <variable name="name"/>
> </head>
> <results>
> <result>
> <binding name="entity">
> <uri>http://airports.dataincubator.org/airports/NGUK</uri>
>
> </binding>
> <binding name="name">
> <literal>Buariki Airport</literal>
> </binding>
> </result>
> <result>
> <binding name="entity">
> <uri>http://airports.dataincubator.org/airports/TQPF</uri>
>
> </binding>
> <binding name="name">
> <literal>Wallblake Airport</literal>
> </binding>
> </result>
> <result>
> <binding name="entity">
> <uri>http://airports.dataincubator.org/airports/SEAM</uri>
>
> </binding>
> <binding name="name">
> <literal>Chachoán Airport</literal>
> </binding>
> </result>
> <result>
> <binding name="entity">
> <uri>http://airports.dataincubator.org/airports/ID-AHI</uri>
>
> </binding>
> <binding name="name">
> <literal>Amahai Airport</literal>
> </binding>
> </result>
> <result>
> <binding name="entity">
> <uri>http://airports.dataincubator.org/airports/OIZB</uri>
>
> </binding>
> <binding name="name">
> <literal>Zabol Airport</literal>
> </binding>
> </result>
> </results>
> </sparql>
>
> The exception in Jena (newest version used via Maven, 2.6.4 at the
moment):
>
> HttpException: HttpException: 500 Internal Server Error: HttpException:
> 500 Internal Server Error
> at
>
com.hp.hpl.jena.sparql.engine.http.HttpQuery.execCommon(HttpQuery.java:337)
> at
> com.hp.hpl.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:189)
> at
> com.hp.hpl.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:144)
> at
>
com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:133)
>
> The code I use for querying is:
>
> QueryEngineHTTP queryExecution = new
> QueryEngineHTTP(sparqlEndpoint, query);
> if(graph!=null) {queryExecution.addDefaultGraph(graph);}
> return queryExecution.execSelect();
>
> Thank you in advance,
> Konrad Höffner
--
PhD Student
IAM Group
Bay 20, Room 4027, Building 32
Electronics & Computer Science
University of Southampton