简体   繁体   中英

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.

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.

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;)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM