QueryEvaluationException while Quering Getty AAT with Java and Sesame Framework

47 views
Skip to first unread message

Julia Iwanowa

unread,
Oct 5, 2015, 5:32:19 AM10/5/15
to Getty Vocabularies as Linked Open Data
Hi,

we are trying to achieve the http://vocab.getty.edu with following code:

 Repository repository = new SPARQLRepository("http://vocab.getty.edu");
        repository.initialize();

        RepositoryConnection connection = repository.getConnection();
        String query = "PREFIX gvp: <http://vocab.getty.edu/ontology#> " +
                "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
                "PREFIX skos: <http://www.w3.org/2004/02/skos/core#> " +
                "SELECT ?c ?label WHERE { " +
                "?c rdf:type gvp:Concept . " +
                "?c skos:prefLabel ?label . " +
                "?c skos:inScheme <http://vocab.getty.edu/aat/> . " +
                "?c luc:term \"skyphos\" . " +
                "FILTER langMatches(lang(?label), \"en\") . " +
                "} " +
                "ORDER BY ASC(?label) " +
                "LIMIT 25";


        TupleQuery tupleQuery = connection.prepareTupleQuery(QueryLanguage.SPARQL, query);

        TupleQueryResult result = tupleQuery.evaluate();
        while (result.hasNext()) {
            BindingSet bs = result.next();
            System.out.println(bs);
        }

We get an exception:
Exception in thread "main" org.openrdf.query.QueryEvaluationException: <html><head><title>Apache Tomcat/7.0.42 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 -.....

The same query is successful via the http://vocab.getty.edu/sparql?query=%09%09%09%09PREFIX%20gvp%3A%20%3Chttp%3A%2F%2Fvocab.getty.edu%2Fontology%23%3E%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PREFIX%20rdf%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PREFIX%20skos%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23%3E%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20SELECT%20%3Fc%20%3Flabel%20WHERE%20{%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Fc%20rdf%3Atype%20gvp%3AConcept%20.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Fc%20skos%3AprefLabel%20%3Flabel%20.%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Fc%20skos%3AinScheme%20%3Chttp%3A%2F%2Fvocab.getty.edu%2Faat%2F%3E%20.%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Fc%20luc%3Aterm%20%22skyphos%22%20.%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20FILTER%20langMatches%28lang%28%3Flabel%29%2C%20%22en%22%29%20.%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ORDER%20BY%20ASC%28%3Flabel%29%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20LIMIT%2025&toc=Finding_Subjects&implicit=true&equivalent=false&_form=/queriesF

Thanks for any help!
Best regards,
Julia

Julia Iwanowa

unread,
Oct 5, 2015, 6:54:10 AM10/5/15
to Getty Vocabularies as Linked Open Data
Hi again,

the same query aginst http://dbpedia.org/sparql  works fine. Are there any getty specific issues?

Thank a lot!
Julia


On Monday, 5 October 2015 11:32:19 UTC+2, Julia Iwanowa wrote:
Hi,

we are trying to achieve the http://vocab.getty.edu with following code:

 Repository repository = new SPARQLRepository("http://vocab.getty.edu/sparql");

Julia Iwanowa

unread,
Oct 5, 2015, 9:11:03 AM10/5/15
to Getty Vocabularies as Linked Open Data
Hi,

the reason was the URI to the SPARQL-Endpoint. The right one is http://vocab.getty.edu/sparql.{rdf || json ..}

Best regards,

Julia

On Monday, 5 October 2015 11:32:19 UTC+2, Julia Iwanowa wrote:

Vladimir Alexiev

unread,
Oct 5, 2015, 3:16:22 PM10/5/15
to Getty Vocabularies as Linked Open Data
Either that, or you have to provide an Accept header. Eg with curl:
curl -Haccept:application/sparql-results+xml "http://vocab.getty.edu/sparql?query=...

BTW, you may prefer to use gvp:prefLabelGVP/xl:literalForm rather than skos:prefLabel: each concept is guaranteed to have exactly 1 gvp:prefLabelGVP (not always in EN). But there might be several prefLabel where langMatches "en".
If you want to sort case-insensitively, see http://vocab.getty.edu/doc/queries/#Case-insensitive_Full_Text_Search_Query. (That query returns more fields, same as the Search function on the UI).
Reply all
Reply to author
Forward
0 new messages