2013-03-13 60 views
0

我正在嘗試從d2rq生成的ttl文件進行查詢。以下是我的代碼片段:無法從Jena查詢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
java.lang.IncompatibleClassChangeError 

在類路徑中有不兼容的jar版本。

如果您使用d2rq中的Jena jar,它們應該是正確的版本,否則您需要針對您要使用的Jena jar編譯的d2rq版本。