sparqlsesameblazegraphopenrdf

Connect to RDF4J server with Sesame library?


I am working on a project that primarily uses Blazegraph as a back-end, and from what I understand, that locks me into a relatively old Sesame (2.7.12).

The project has another component that can use an embedded Sesame, or a free-standing Sesame OR RDF4J. I have a free-standing RDF4J already set up, so I'd prefer to use that.

I can connect to the embedded Sesame with the following Scala code. If I change serverUrl to point to the free-standing RDF4J 2.2, I get the error below.

Is it possible to access RDF4J servers with the Sesame API?

val serverUrl = "http://address.domain:8080/rdf4j-server"
val manager = new RemoteRepositoryManager(serverUrl)
manager.initialize()
val repositoryId = "repo_id"
val repository = manager.getRepository(repositoryId)
val con = repository.getConnection()
val queryString = "SELECT ?x ?y WHERE { ?x ?p ?y } "
val tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString)
val result = tupleQuery.evaluate()

[main] WARN org.openrdf.http.client.SesameSession - Server reports problem: org.eclipse.rdf4j.repository.config.RepositoryConfigException: Repository implementation for repository missing Exception in thread "main" java.lang.ExceptionInInitializerError at UuidRefresh.main(UuidRefresh.scala) Caused by: org.openrdf.repository.http.HTTPQueryEvaluationException: org.eclipse.rdf4j.repository.config.RepositoryConfigException: Repository implementation for repository missing at org.openrdf.repository.http.HTTPTupleQuery.evaluate(HTTPTupleQuery.java:64) at UuidRefresh$.(UuidRefresh.scala:54) at UuidRefresh$.(UuidRefresh.scala) ... 1 more Caused by: org.openrdf.repository.RepositoryException: org.eclipse.rdf4j.repository.config.RepositoryConfigException: Repository implementation for repository missing at org.openrdf.http.client.SparqlSession.execute(SparqlSession.java:1100) at org.openrdf.http.client.SparqlSession.executeOK(SparqlSession.java:1028) at org.openrdf.http.client.SparqlSession.sendTupleQueryViaHttp(SparqlSession.java:807) at org.openrdf.http.client.SparqlSession.getBackgroundTupleQueryResult(SparqlSession.java:704) at org.openrdf.http.client.SparqlSession.sendTupleQuery(SparqlSession.java:363) at org.openrdf.repository.http.HTTPTupleQuery.evaluate(HTTPTupleQuery.java:58) ... 3 more


Solution

  • I'm not 100% sure you would be able to access an RDF4J remote repository as a Sesame HTTPRepository, especially when your client library is that old. Sesame version 2.7 is quite ancient and a lot of improvements have been done to the REST API since then - they should be backwards compatible, but...

    However, given that an RDF4J repository running on RDF4J Server is a SPARQL endpoint, you can of course always access it as you would any SPARQL endpoint, by creating a SPARQLRepository object.

    As an aside: do let the Blazegraph folks know that you'd like to upgrade to RDF4J. Them prioritizing RDF4J support is governed by user demand (as it should be), so let them know it's important to you!