在Apache Jena中执行SPARQL查询时获取ClassCastException。

时间:2016-10-30 12:26:39

标签: java sparql apache-jena

我是使用Apache Jena的新手! 以下是我的代码。 exec.execSelect()的异常,任何人都可以说出原因吗?

public static void main(String [] args){
        ParameterizedSparqlString qs = new ParameterizedSparqlString(""
                + "prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#>\n"
                + "PREFIX dbo:     <http://dbpedia.org/ontology/>"
                + "\n"
                + "select distinct ?resource ?abstract where {\n"
                + "  ?resource rdfs:label 'Ibuprofen'@en.\n"
                + "  ?resource dbo:abstract ?abstract.\n"
                + "  FILTER (lang(?abstract) = 'en')}");


        QueryExecution exec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", qs.asQuery());

        ResultSet results = exec.execSelect();

        while (results.hasNext()) {

            System.out.println(results.next().get("abstract").toString());
        }

        ResultSetFormatter.out(results);
    }

而且例外是

  

线程中的异常&#34; main&#34; java.lang.ClassCastException:   java.lang.Long无法强制转换为java.lang.Integer at   org.apache.http.params.AbstractHttpParams.getIntParameter(AbstractHttpParams.java:70)     在   org.apache.http.client.params.HttpClientParamConfig.getRequestConfig(HttpClientParamConfig.java:54)     在   org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:806)     在   org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)     在   org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)     在   org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:158)     在   org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:139)     在org.apache.jena.riot.web.HttpOp.exec(HttpOp.java:1097)at   org.apache.jena.riot.web.HttpOp.execHttpGet(HttpOp.java:378)at at   org.apache.jena.riot.web.HttpOp.execHttpGet(HttpOp.java:440)at   org.apache.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:343)     在   org.apache.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:292)     在   org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:345)     在   org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:337)     在trial.SecondAttempt.main(SecondAttempt.java:32)

0 个答案:

没有答案