2

For a project I have to use Apache Jena combined with Blazegraph as triplestore. But I have problems connecting Jena to Blazegraph by using RDFConnection.

RDFConnection conn = RDFConnectionFactory.connect(...)
conn.load("data.ttl") ;
QueryExecution qExec = conn.query("SELECT DISTINCT ?s { ?s ?p ?o }") ;
ResultSet rs = qExec.execSelect() ;
while(rs.hasNext()) {
    QuerySolution qs = rs.next() ;
    Resource subject = qs.getResource("s") ;
    System.out.println("Subject: "+subject) ;
}
qExec.close() ;
conn.close() ;

Blazegraph including its webinterface is running. This is the commandline output.

Welcome to the Blazegraph(tm) Database.

Go to http://192.168.222.1:9999/blazegraph/ to get started. WARN : MapgraphServletProxy.java:67: Running without GPU Acceleration. See >https://www.blazegraph.com/product/gpu-accelerated/.

I already read the examples at https://github.com/apache/jena/tree/master/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples

RDFConnection conn = RDFConnectionFactory.connect("http://192.168.222.1:9999/blazegraph/");
conn.load("d:\\data.ttl") ;

leads to:

Exception in thread "main" org.apache.jena.atlas.web.HttpException: 404 - Not Found

At conn.load("d:\data.ttl") ;

Using "http://192.168.222.1:9999" as destination results in the same Exception.

Using "http://192.168.222.1/blazegraph" or "http://192.168.222.1"

lead to:

Exception in thread "main" org.apache.jena.atlas.web.HttpException: org.apache.http.conn.HttpHostConnectException: Connect to 192.168.222.1:80 [/192.168.222.1] failed: Connection refused: connect

at conn.load("data.ttl") ; also.

Could you please help me to find the correct way of connecting.

andreask
  • 109
  • 1
  • 13
  • At what line is the problem? Are you connecting to the right URL? `conn.load` is Graph Store Protocol, `conn.query` is SPARQL Query protocol. Some servers use the same URL, some don't. – AndyS Jan 19 '18 at 11:53
  • Sorry, I forgot to mention my used URLs and the Exceptions.I edited/updated the question. – andreask Jan 19 '18 at 12:16
  • The error may be indicating that the file you're trying to load cannot be found rather than a problem connecting to the server. – Mark Jan 19 '18 at 14:35
  • 1
    Check the Blazegraph documentation. The usual SPARQL endpoint is `http://localhost:9999/bigdata/sparql`, not `/` or `/warfilename`. – AndyS Jan 19 '18 at 15:19
  • 1
    Thank you very much. I was confused because the cmd showed me: Go to 192.168.222.1:9999/blazegraph to get started | This the IP4-address of VMware Virtual Ethernet Adapter at my system. So localhost:9999, 192.168.178.159:9999 or 192.168.222.1:9999 are ok for the host part. You are right I have overlooked the part with the correct route. Valid routes are /bigdata/sparql or /blazegraph/sparql . But I made also another mistake which I will show in an answer. – andreask Jan 19 '18 at 18:31

1 Answers1

2

One solution for the problem

String APIUrl = "http://192.168.222.1:9999/bigdata/sparql";
RDFConnection conn = RDFConnectionFactory.connect(APIUrl,APIUrl,APIUrl);

https://jena.apache.org/documentation/javadoc/rdfconnection/org/apache/jena/rdfconnection/RDFConnectionFactory.html#connect-java.lang.String-java.lang.String-java.lang.String-

andreask
  • 109
  • 1
  • 13