2

Dear Friends I m using Jena framework with RDF database model with virtuoso in my project. my jena version is jena-core2.7.2 and jena-arq-2.9.2

Here is the my code which is giving me error

public JsonArray getCountryAutoSuggestData()
{
    JsonArray countryArray = new JsonArray();
    Model model = DataModel.getModel();
    String mystr = " PREFIX plcontologyurl:<http://www.plcontology.com/#> "
            + " PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
            + "select ?cn"
            + " where "
            + " { "
            + " ?d plcontologyurl:Country_Name ?cn . "
            + "}";
    Query query = QueryFactory.create(mystr);
    QueryExecution qe = QueryExecutionFactory.create(query, model);
    QuerySolutionMap qMap = new QuerySolutionMap();
    qe.setInitialBinding(qMap);
    ResultSet rs = qe.execSelect();
    while(rs.hasNext())
    {
        qMap = (QuerySolutionMap)rs.next();
        countryArray.add(new JsonPrimitive(qMap.getLiteral("cn").getString()));
    }
    return countryArray;
}

Error is java.lang.InstantiationError: com.hp.hpl.jena.sparql.engine.binding.BindingMap at line while(rs.hasNext())

I tried looking for the problem and I found one relevant discussion

They are saying that now com.hp.hpl.jena.sparql.engine.binding.BindingMap is not a simple class now in this version but an interface now.

If it is like that then how to run sparql query in the current version. Please give an example based on the code i have shared. Thanks in advance.

1 Answer 1

4

You have a mix of versions on the classpath.

The information you link to is correct - BindingMap became an interface so if you see java.lang.InstantiationError it means the calling code is from an earlier version of ARQ.

Check you don't have more than one copy of Jena code on the classpath, and there are not copies in endorsed directories of the JVM.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.