Search code examples
javasparqljenafuseki

Insert SPARQL query with Java jena to upload triples in fuseki


I'm trying to create an INSERT query within my Java web application using the jena framework. I want to insert some triples to a specific named graph in my Fuseki triple store. I have tried using the code below

UpdateRequest update = UpdateFactory.create("INSERT DATA { graph <http://graph/my> { "+ string_triples + "}}");
UpdateProcessor processor = UpdateExecutionFactory.createRemote(update, "http://fusekidomain/ds/sparql");
processor.execute();

but it hasn't worked, I get a "java.lang.ClassNotFoundException: org.apache.http.protocol.HttpContext" error.

I'm guessing I'm missing something in my code but I'm not sure what it is.


Solution

  • java.lang.ClassNotFoundException : there is at least one jar missing from the classpath of your program.

    Either use maven or other build tool to manage the dependencies or put all the jars from the Jena distribution lib directory on the classpath.