简体   繁体   中英

Load data into AWS Neptune via Apache Jena: "Missing 'query' > or 'update' parameter for POST request"

I am trying to load data from a garden-variety Spring Boot application into an AWS Neptune store, via Apache Jena (3.14.0).

The code I'm working with has been written and works with a few triple stores, including Anzo and Fuseki.

The setup to even get connectivity to the Neptune store from my local development environment is a Rube-Goldberg machine I'm ashamed of discussing here - however, the connectivity "works" as of now.

My problem comes specifically with loading data into the store (think POST operations).

The operation fails when loading a Jena Model , via the RDFConnection#load(String, Model) idiom.

The stack trace looks like:

org.apache.jena.atlas.web.HttpException: 400 - Bad Request
    at org.apache.jena.riot.web.HttpOp.exec(HttpOp.java:1091)
    at org.apache.jena.riot.web.HttpOp.execHttpPost(HttpOp.java:721)
    at org.apache.jena.rdfconnection.RDFConnectionRemote.lambda$doPutPost$9(RDFConnectionRemote.java:458)
    at org.apache.jena.rdfconnection.RDFConnectionRemote.exec(RDFConnectionRemote.java:668)
    at org.apache.jena.rdfconnection.RDFConnectionRemote.doPutPost(RDFConnectionRemote.java:453)
    at org.apache.jena.rdfconnection.RDFConnectionRemote.load(RDFConnectionRemote.java:366)
    at [my loading code here]

More helpfully maybe, the error message from the response is:

Http exception response {"code":"MissingParameterException","detailedMessage":"Missing 'query' or 'update' parameter for POST request","requestId":"[some UUID]"}

The AWS docs with regards to common errors seem to be of no use here.

The text of the error message seems clear "in a way" - the request is missing a parameter.

I haven't had a close look yet on how Jena builds the request in the first place (since my usage of the framework works fine with other triple stores), and neither do I understand how to add extra parameters, from the RDFConnection javadoc .

I also haven't tried to send a SPARQL request manually to the store, eg via a REST client - but I want to use Jena in the first place, so it's probably not ideal to linger so far beyond.

The AWS tutorial on using Neptune with Jena is very basic and only reads from the triple store - so once again, no cookie there.

Again, same stack, same code, same data, other store --> works fine.

Is there any simple way around this issue, or maybe some documentation/examples I've missed out on?

Bulk load into Netpune seems to be feasible in a two step process via RDF4J. Wrote a program to generate an RDF (NT file) and then used RDF4J console to load it manually into Neptune.

Guess: If we dig in a bit more into RDF4J and how Neptune is accepting bulk load from it, it might be feasible to do the entire load within the same program.

$ ./bin/console.sh
04:10:40.412 [main] DEBUG org.eclipse.rdf4j.common.platform.PlatformFactory - os.name = linux
04:10:40.416 [main] DEBUG org.eclipse.rdf4j.common.platform.PlatformFactory - Detected Posix platform
Connected to default data directory
RDF4J Console 3.6.3
Working dir: /home/bitnami/tools/eclipse-rdf4j-3.6.3
Type 'help' for help.
> create sparql
Please specify values for the following variables:
SPARQL query endpoint: https://yyy.cluster-xxx.us-east-1.neptune.amazonaws.com:8182/sparql
SPARQL update endpoint: https://yyy.cluster-xxx.us-east-1.neptune.amazonaws.com:8182/sparql
Local repository ID [endpoint@localhost]: test
Repository title [SPARQL endpoint repository @localhost]: test Graph data model PoC
Repository created
> open test

test> sparql select ?s ?p ?o where {?s ?p ?o} limit 10
Evaluating SPARQL query...
+------------------------+------------------------+------------------------+
| s                      | p                      | o                      |
+------------------------+------------------------+------------------------+
| <https://test.com/s>   | <https://test.com/p>   | <https://test.com/o>   |
+------------------------+------------------------+------------------------+
1 result(s) (671 ms)

test> clear

test> load /home/bitnami/projects/model/sparql-client/output/model.nt

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