0

我正在尝试从 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)

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

4

1 回答 1

1
java.lang.IncompatibleClassChangeError

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

如果您使用 d2rq 中的 Jena jar,它们应该是正确的版本,否则您需要针对您希望使用的 Jena jar 编译的 d2rq 版本。

于 2013-03-13T12:00:21.867 回答