我們有一個調用Virtuoso的Java應用程序。如果它在Virtuoso執行檢查點時運行一些SPARQL查詢,它會給出:"com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP: File not found"
爲什麼我會在Virtuoso檢查點獲得`404 File not found`(通過Jena)?
我的第一個想法是因爲CheckpointSyncMode=2
,它阻止了查詢。但是當CheckpointSyncMode=1
時我設法得到這個例外。
不幸的是,我不能複製比方法調用更多的代碼;但我可以用任何SPARQL查詢重現它。
ResponseResult resultsAndBindings = APIEndpointUtil.call(req, nb, match, contextPath, queryParams);
這裏是堆棧跟蹤:
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
沒有按沒關係;無論如何它都會發生。
確保炫技忙於檢查點:
#!/bin/bash
while true; do
isql-vt 1111 dba dba exec="checkpoint;"
done;
呼叫與耶拿(附: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)
沒有看到你所說的整個代碼和錯誤堆棧跟蹤,無法幫助... – AKSW
感謝您的反饋,更新了問題。 –
錯誤說「HttpException:404 File not found」;我猜你已經得到了錯誤的端點URI。沒有更多的代碼,不可能說。 –