I am trying to query from a d2rq-generated ttl file. Following is my code snippet:
ModelD2RQ m = new ModelD2RQ("file:C:\\Users\\599782\\Downloads\\d2rq-0.8.1\\northwind.ttl");
String sparql =
"PREFIX vocab: <http://localhost:2020/resource/vocab/>" +
"select ?firstname ?lastname where{"+
"?x vocab:employees_Country 'USA'."+
"?x vocab:employees_FirstName ?firstname."+
"?x vocab:employees_LastName ?lastname."+
"}";
Query q = QueryFactory.create(sparql);
ResultSet rs = QueryExecutionFactory.create(q, m).execSelect();
ResultSetFormatter.out(System.out, rs, q);
m.close();
And it shows this exception:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Class com.hp.hpl.jena.sparql.algebra.op.OpProject does not implement the requested interface org.openjena.atlas.io.Printable
at org.openjena.atlas.io.PrintUtils.toString(PrintUtils.java:28)
at de.fuberlin.wiwiss.d2rq.engine.QueryEngineD2RQ.translate(QueryEngineD2RQ.java:70)
at de.fuberlin.wiwiss.d2rq.engine.QueryEngineD2RQ.modifyOp(QueryEngineD2RQ.java:60)
at com.hp.hpl.jena.sparql.engine.QueryEngineBase.createPlan(QueryEngineBase.java:94)
at com.hp.hpl.jena.sparql.engine.QueryEngineBase.getPlan(QueryEngineBase.java:87)
at de.fuberlin.wiwiss.d2rq.engine.QueryEngineD2RQ$QueryEngineFactoryD2RQ.create(QueryEngineD2RQ.java:110)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.getPlan(QueryExecutionBase.java:513)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.startQueryIterator(QueryExecutionBase.java:490)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execResultSet(QueryExecutionBase.java:498)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execSelect(QueryExecutionBase.java:194)
at com.jenaproj.HelloJena.main(HelloJena.java:159)
Anyone have any idea what might be going on.
java.lang.IncompatibleClassChangeError
You have incompatible versions of the jars on your classpath.
If you use the Jena jars from d2rq they should be the correct version, otherwise you need a version of d2rq compiled against the Jena jars you wish to use.