无法从Jena查询d2rq ttl文件

时间:2013-03-13 09:12:29

标签: jena d2rq

我正在尝试从d2rq生成的ttl文件进行查询。以下是我的代码段:

        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();

它显示了这个例外:

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)

任何人都知道可能会发生什么。

1 个答案:

答案 0 :(得分:1)

java.lang.IncompatibleClassChangeError

您的类路径上有不兼容的jar版本。

如果你使用d2rq的Jena罐子,它们应该是正确的版本,否则你需要一个针对你想要使用的Jena罐子编译的d2rq版本。