我们有一个叫做Virtuoso的Java应用程序。如果它在Virtuoso执行检查点时运行某些SPARQL查询,则会给出:"com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP: File not found"
我的第一个想法是因为CheckpointSyncMode=2
,它会阻止查询。但是我在CheckpointSyncMode=1
时设法得到了这个例外。
不幸的是,我无法复制比方法调用更多的代码;但我可以使用任何SPARQL查询重现它。
ResponseResult resultsAndBindings = APIEndpointUtil.call(req, nb, match, contextPath, queryParams);
这是stacktrace:
HttpException: 404 File not found
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execCommon(HttpQuery.java:446)
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execPost(HttpQuery.java:344)
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:239)
at com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:302)
at com.epimorphics.lda.sources.SourceBase.executeSelect(SourceBase.java:110)
at com.epimorphics.lda.query.APIQuery.requestTotalCount(APIQuery.java:917)
at com.epimorphics.lda.core.APIEndpointImpl.call_revised(APIEndpointImpl.java:112)
at com.epimorphics.lda.core.APIEndpointImpl.call(APIEndpointImpl.java:92)
at com.epimorphics.lda.core.APIEndpointUtil.call(APIEndpointUtil.java:53)
在非常简单的测试环境中重现:
我设置了一个空的Virtuoso实例:
OpenLink Virtuoso Server
Version 07.20.3215-pthreads for Linux as of Jan 20 2016"
CheckpointSyncMode=2
或CheckpointSyncMode=1
并不重要;无论如何它都会发生。
确保Virtuoso忙于检查点:
#!/bin/bash
while true; do
isql-vt 1111 dba dba exec="checkpoint;"
done;
使用Jena(使用:com.epimorphics.lda:elda-lda:1.3.16
,jena-core:2.10.1
)调用端点:
import com.hp.hpl.jena.query.ParameterizedSparqlString;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QuerySolution;
public class Main {
public static void main(String args[]){
while(true)
getPreviousSnapshot();
}
public static void getPreviousSnapshot() {
ParameterizedSparqlString pss = new ParameterizedSparqlString("SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o }}");
System.out.println("Executing SPARQL query:" + pss.toString());
QueryExecution qe = QueryExecutionFactory.sparqlService("http://33.33.33.11:8890/sparql", pss.asQuery());
com.hp.hpl.jena.query.ResultSet resultSet = qe.execSelect();
processResultSet(resultSet);
qe.close();
}
private static void processResultSet(com.hp.hpl.jena.query.ResultSet results) {
while (results.hasNext()) {
QuerySolution qs = results.next();
String s = qs.getResource("g").toString();
System.out.println(s);
}
}
}
输出:
Executing SPARQL query:SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o }}
http://www.openlinksw.com/schemas/virtrdf#
http://www.w3.org/ns/ldp#
http://localhost:8890/sparql
http://localhost:8890/DAV/
http://www.w3.org/2002/07/owl#
Executing SPARQL query:SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o }}
Exception in thread "main" HttpException: 404 File not found
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execCommon(HttpQuery.java:446)
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:289)
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:240)
at com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:302)
at Main.getPreviousSnapshot(Main.java:21)
at Main.main(Main.java:11)
答案 0 :(得分:0)
根据我在virtuoso邮件列表上得到的答案:当由于执行检查点(这是Virtuoso中的原子操作)而暂时无法访问Virtuoso时,Jena与SPARQL服务没有任何关联,因此只返回404错误