简体   繁体   中英

HttpException: 400 - Jena Api - Java

I tried to run this query using Jena Api in Java.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
select distinct ?p where {
    ?s ?p ?o .
    {
        select ?s {
        ?s a <http://data.linkedmdb.org/resource/movie/film> .
        }
    limit 10
    }
}

I get this error message :

Exception in thread "main" HttpException: 400
    at com.hp.hpl.jena.sparql.engine.http.HttpQuery.rewrap(HttpQuery.java:414)
    at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:358)
    at com.hp.hpl.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:295)

I think this may have to do with the fact that LinkedMDB endpoint is running under SPARQL 1.0, which does not support subqueries (only in SPARQL 1.0). I was wondering whether there is an alternative to this, I tried to run two queries, first one for the first 10 movies, and the second for the distinct properties describing these movies. But the problem is I get the distinct properties of each of the movies, not all of them, whereas I want to get the distinct properties of all the 10 first movies. Any suggestion?

PS. The SPARQL query works perfectly on DBpedia endpoint.

I don't think the LinkedMDB endpoint is virtuoso based. The webapp endpoint, at http://www.linkedmdb.org/snorql/ , is powered by D2R server, and the actual webservice, at http://www.linkedmdb.org/sparql , reports that's powered by Jetty. That doesn't mean that there couldn't be Virtuoso underneath somewhere, but I don't think it's Virtuoso based. More authoritatively, the LinkedMDB website says:

LinkedMDB publishes linked open data using the D2R Server.

The copyright date on the LinkedMDB page is 2008, which is certainly before the 2013 SPARQL 1.1, but much closer to the original SPARQL's 2008.

The DR2 server was updated in 2012 to provide preliminary support for SPARQL 1.1, but I don't think that's been applied to the LinkedMDB site. It's been other people's experience, too, that the LinkedMDB endpoint doesn't support SPARQL 1.1:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM