Uploading an RDFXML file to Stardog 4.2 - What encoding should be given?

13 views
Skip to first unread message

fabio.f...@gmail.com

unread,
Feb 6, 2017, 9:04:13 AM2/6/17
to Stardog
Hello,

I am trying to construct a CURL command in order to upload RDF Files (could be any RDF type).
The command I am using (on a SIERRA OSX system) is the following (see below).

The server does not respond with a 200, although I have read http://docs.stardog.apiary.io/ I cannot figure out how the CURL should finally be (also with the indication of the file type (TTL, RDFXML, NT, etc...).

WHAT AM I DOING WRONG please?

It seems that some headers are yet missing, since the result encoder throws an exception. I am also not sure whether "Content-Type: application/x-www-form-urlencoded" is needed here.

Thanks a lot in advance
Cheers


PS:
Here my data:

/usr/bin/curl -v -k --basic -u trial:trial -H "Accept: */*" -H "Content-Type: application/x-www-form-urlencoded"  --url http://ch.semweb.ch:23458/STARDOGENGINES/query -X POST -T /filepath.rdf 2>&1
That server http://ch.semweb.ch:23458  is actually usable for tests, in case somebody from stardog want to test the curl directly there.


The curl resul is:

*   Trying 93.184.26.24...

* TCP_NODELAY set

* Connected to ch.semweb.ch (93.184.26.24) port 23458 (#0)

* Server auth using Basic with user 'trial'

> POST /STARDOGENGINES/query HTTP/1.1

> Host: ch.semweb.ch:23458

> Authorization: Basic dHJpYWw6dHJpYWw=

> User-Agent: curl/7.51.0

> Accept: */*

> Content-Type: application/x-www-form-urlencoded

> Content-Length: 1963

> Expect: 100-continue




* Done waiting for 100-continue

* We are completely uploaded and fine

< HTTP/1.1 500 There was a fatal error on the server

< Content-Length: 37

* Curl_http_done: called premature == 0

* Connection #0 to host ch.semweb.ch left intact

There was a fatal error on the server



And on the server log says:

java.lang.NullPointerException
at com.complexible.stardog.protocols.http.server.io.ResponseBodyEncoders$12.encode(ResponseBodyEncoders.java:418) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.io.ResponseBodyEncoders$2.encode(ResponseBodyEncoders.java:104) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.HttpMessageEncoder$SingletonMessageResponseBodyEncoder.encode(HttpMessageEncoder.java:512) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.HttpMessageEncoder.write(HttpMessageEncoder.java:158) [stardog-protocols-http-server-4.2.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:633) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext.access$1900(AbstractChannelHandlerContext.java:32) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:908) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:893) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]
ERROR 2017-02-06 14:54:01,447 [StardogServer.WorkerGroup-13] com.complexible.stardog.protocols.http.server.HttpMessageEncoder:write(171): There was an error writing the HTTP response
java.lang.NullPointerException
at com.complexible.stardog.protocols.http.server.io.ResponseBodyEncoders$12.encode(ResponseBodyEncoders.java:418) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.io.ResponseBodyEncoders$2.encode(ResponseBodyEncoders.java:104) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.HttpMessageEncoder$SingletonMessageResponseBodyEncoder.encode(HttpMessageEncoder.java:512) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.HttpMessageEncoder.write(HttpMessageEncoder.java:158) [stardog-protocols-http-server-4.2.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:633) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext.access$1900(AbstractChannelHandlerContext.java:32) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:908) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:893) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]
ERROR 2017-02-06 14:54:01,447 [StardogServer.WorkerGroup-13] com.complexible.stardog.protocols.http.server.HttpMessageEncoder:createErrorResponse(288): The result encoder received an error message it could not encode, error was:
java.lang.NullPointerException
at com.complexible.stardog.protocols.http.server.io.ResponseBodyEncoders$12.encode(ResponseBodyEncoders.java:418) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.io.ResponseBodyEncoders$2.encode(ResponseBodyEncoders.java:104) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.HttpMessageEncoder$SingletonMessageResponseBodyEncoder.encode(HttpMessageEncoder.java:512) ~[stardog-protocols-http-server-4.2.jar:?]
at com.complexible.stardog.protocols.http.server.HttpMessageEncoder.write(HttpMessageEncoder.java:158) [stardog-protocols-http-server-4.2.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:633) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext.access$1900(AbstractChannelHandlerContext.java:32) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:908) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:893) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [netty-all-4.0.32.Final.jar:4.0.32.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]

Zachary Whitley

unread,
Feb 6, 2017, 9:33:14 AM2/6/17
to Stardog
I think the problem is you are looking for an equivalent to the "stardog data add" command but I don't think there is an equivalent in the REST api. The rest API expects either SPARQL queries or SPARQL update queries. These are handled by two separate end points. It looks like you're trying to hit the query endpoint http://ch.semweb.ch:23458/STARDOGENGINES/query . The update endpoint would be http://ch.semweb.ch:23458/STARDOGENGINES/update

The update endpoint will expect a valid sparql update query [1] not just raw triples. There are two ways to load data, you can use an INSERT [2] or a LOAD [3]. If you already have your data in turtle you can just wrap it with INSERT DATA { ....your ttl data... } and you should be set otherwise you'll need to make sure the data is accessible via url and use LOAD


I think that should get you going. Let me know if you still have any problems. 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+unsubscribe@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

Zachary Whitley

unread,
Feb 6, 2017, 9:35:51 AM2/6/17
to Stardog
Sorry, Stardog also supports the graph store protocol which would be more like what you're looking to do. https://www.w3.org/TR/sparql11-http-rdf-update/

fabio.f...@gmail.com

unread,
Feb 6, 2017, 10:19:58 AM2/6/17
to Stardog
Hi Zachary - thank you a lot.

So, there is no way (up to today, maybe things change in the future) to upload an RDF file (e.g. RDFXML) directly from a file system to a current stardog instance.

Resuming what I understood:
The only way is to upload a file is to use LOAD as SPARQL-UPDATE COMMAND, pointing to a filepath and using http://ch.semweb.ch:23458/STARDOGENGINES/update 

You know, many RDF stores (virtuoso, blazegraph, marklogic) have bulkload facilicies, and that is really useful since the first thing you do is load some data :) - now I am here requiring that that file load be pursued via HTTP thus using the REST API.

I would not use the option of opening the file (in RDFXML), or reading the file into sesame, then create some NTRIPLES model and create a huge CONSTRUCT to insert all that data. That might be a nice school exercise but it would be quite inefficient to work quickly... don't you think so?

I will now try to construct a CURL command using a LOAD pointing to a filepath and using the /upload servlet to process.

Thank you
Cheers



For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.


Bill Roberts

unread,
Feb 6, 2017, 10:28:53 AM2/6/17
to sta...@clarkparsia.com
Hi Fabio

See the following sections of the Stardog docs for how to add data via an HTTP API:


If I understand your question correctly, I think this will explain what to do

Best regards

Bill



For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

Zachary Whitley

unread,
Feb 6, 2017, 10:31:43 AM2/6/17
to Stardog
I apologize, I wasn't being clear. (I've got a bit of a cold so I'm not at my sharpest). The API documented on http://docs.stardog.apiary.io and what it appeared that you were trying to use is for SPARQL and SPARQL/UPDATE queries and you can load data as you mentioned. The apiary docs also mention "Stardog supports the SPARQL and Graph Store protocols." but you'll need to look here [1] for documentation on how to use it. I couldn't tell from what you were doing if you were intending to do was to use sparql queries or the graph store protocol to load your data. (It looked like a little of both)

The following documented under the section 5.5 HTTP POST should get you what you're looking for

    POST /rdf-graph-store?default HTTP/1.1
    Host: example.com
    Content-Type: text/turtle
    
    ... RDF payload ... 


For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

fabio.f...@gmail.com

unread,
Feb 6, 2017, 10:42:33 AM2/6/17
to Stardog
Thanks a lot, Zachary

I will follow that :)

By the way the command I tried to issue upon what I understood (see below) threw a 500 ... (is not the way I guess).

But now on the rdf-update W3C doc :)

Wish you get soon rid of that cold
Fabio


/usr/bin/curl -v -k --basic -u trial:trial --url http://ch.semweb.ch:23458/STARDOGENGINES/update --data 'LOAD </uploads/1486395277649_small_file_cylinder.rdf>' -X POST 2>&1

Note: Unnecessary use of -X or --request, POST is already inferred.

*   Trying 93.184.26.24...

* TCP_NODELAY set

* Connected to ch.semweb.ch (93.184.26.24) port 23458 (#0)

* Server auth using Basic with user 'trial'

> POST /STARDOGENGINES/update HTTP/1.1

> Host: ch.semweb.ch:23458

> Authorization: Basic dHJpYWw6dHJpYWw=

> User-Agent: curl/7.51.0

> Accept: */*

> Content-Length: 152

> Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 152 out of 152 bytes

< HTTP/1.1 500 There was a fatal error on the server

< Content-Length: 37

* Curl_http_done: called premature == 0

* Connection #0 to host ch.semweb.ch left intact

fabio.f...@gmail.com

unread,
Feb 6, 2017, 10:55:18 AM2/6/17
to Stardog, fabio.f...@gmail.com
I am sorry but not even the example depicted in the W3C document will function. All the example below do not function (500):  malformed query.
 

/usr/bin/curl -v -k -H 'Content-Type: application/sparql-update' --basic -u trial:trial --url http://ch.semweb.ch:23458/STARDOGENGINES/update --data 'update=INSERT DATA { GRAPH <http://semweb.ch/base/> {</uploads/1486395277649_small_file_cylinder.rdf> }}' -X POST 2>&1


/usr/bin/curl -v -k -H 'Content-Type: application/sparql-update' --basic -u trial:trial --url http://ch.semweb.ch:23458/STARDOGENGINES/update --data 'INSERT DATA { GRAPH <http://semweb.ch/base/> {</uploads/1486395277649_small_file_cylinder.rdf> }}' -X POST 2>&1


What am I doing wrong please?

Attached the file I try to upload.

Thanks in advance
Regards
small_file_cylinder.rdf

Zachary Whitley

unread,
Feb 6, 2017, 11:05:04 AM2/6/17
to Stardog
Thanks Fabio.

I think you're close. You're trying to execute an INSERT DATA query but passing it the URL for your data. You either need to put the actual data in there in turtle format or use LOAD DATA and make sure it can download the data from the url that you give it.


For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

Fabio Ricci

unread,
Feb 6, 2017, 3:54:30 PM2/6/17
to sta...@clarkparsia.com
Hi Bill

thanks a lot! 
The needed command will be for me


/usr/bin/curl -v -k --basic -u trial:trial -H "Content-Type: application/rdf+xml" -X POST --url http://ch.semweb.ch:34233/STARDOGENGINES --data @/pathto/rdffile.rdf

That will upload the RDF file to the RDF repository.

Thank you all.
Fabio

(this thread can be closed)

You received this message because you are subscribed to a topic in the Google Groups "Stardog" group.
To unsubscribe from this topic, visit https://groups.google.com/a/clarkparsia.com/d/topic/stardog/TGi9h47_1uk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stardog+u...@clarkparsia.com.

signature.asc
Reply all
Reply to author
Forward
0 new messages