0

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.

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
MariaZ
  • 27
  • 3
  • `java.lang.ClassNotFoundException` has nothing to do with your code but with the Java class path, i.e. which libraries your have there. If you use Jena, you have to add **all libraries** from the Jena distribution to the classpath or **use Maven** (resp. Gradle) – UninformedUser Apr 23 '17 at 12:28

3 Answers3

2

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.

AndyS
  • 16,345
  • 17
  • 21
1

Check for possible dependency conflicts in your project. Sometimes this error happens when another dependency is not using the same version of a library imported by another dependency (see this post).

If your project is a maven project, you can list all dependencies with the command:
mvn dependency:tree -Dverbose

Hope it helps ;)

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Antoine
  • 1,393
  • 4
  • 20
  • 26
0

Thank you both for your answers. It turns out I was indeed missing some jars and I had one jar that was duplicate, hence the no class found exception. When I added them it worked fine.

MariaZ
  • 27
  • 3