java - Sesame/Jena SPARQL results to JSON-LD -


i've seen answer on how return sparql results in json-ld?, it's not satisfying/working. used json-ld java integration sesame, standalone version.

what want achieve: send sparql construct query sparql endpoint via blazegraph remoterepository (based on sesame/sail), rdf result, serialize rdf json-ld. rdf result works fine.

the problem is, following code (with sesame) producing no output:

stringwriter sw = new stringwriter(); final rdfwriter writer = rio.createwriter( rdfformat.jsonld, sw ); //writer.getwriterconfig().set( jsonldsettings.jsonld_mode, jsonldmode.compact ); graphqueryresult queryresults; rio.write(queryresults.asmodel(queryresults), writer); 

i used conversion jena internal model, because know jena json-ld output worked fine in side project of mine. unfortunately, same approach doesn't work conversion jena.

my code sesame jena adapter:

while(queryresults.hasnext()) {     jenautils.asjenastatement(); } stringwriter sw = new stringwriter(); // jenautils.getmodel() returns jena model added statements above rdfdatamgr.write( sw, jenautils.getmodel(), rdfformat.jsonld ); 

what can now?

ok, problem not process mentioned above.

the issue caused due supressed exception in json-ld sesame integration library incompatible version of http client in blazegraph.

java.lang.noclassdeffounderror: org/apache/http/impl/client/systemdefaulthttpclient 

resulted in not piping graphqueryresults json-ld. exception happened due blazegraph's incompatible http client version (4.1.3), overrode json-ld http client version (>4.1.3).

you have override project's dependency on http client following:

<!-- necessary (sesame) json-ld integration, --> <!-- because blazegraph uses older version. see https://github.com/jsonld-java/jsonld-java/issues/64 -->   <dependency>      <groupid>org.apache.httpcomponents</groupid>      <artifactid>httpclient</artifactid>      <version>4.4</version>   </dependency> 

i hope safe someone's time!


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -