I can make it happen sporadically using Fuseki main (so no shiro, not a
webapp environment). It happens maybe one in four test runs.
It looks like a client-side problem - it creates the HTTP connection
each time and maybe something is cached in HttpClient. A hash-map-ism
would explain the "sporadically". If so, the # triples effect maybe
causing the timing to get changed a little.
Andy
On 31/10/2019 13:27, Sebastian Trueg wrote:
Interestingly it does not. Only going down to a really small number of
triples does work.
And to make sure I did implement manual HTTP DELETE+PUT via OkHttp which
works without problems on the same Fuseki instance.
Regards,
Sebastian
On 31.10.19 14:14, Andy Seaborne wrote:
Thanks.
Presumably it works if you create the RDFConnection once and reuse the
java object?
Andy
On 31/10/2019 12:10, Sebastian Trueg wrote:
Hi Andy,
- Fuseki started via "fuseki-server".
- shiro config attached
- "pdm-data-model" dataset created via attached config
- Simple test app attached which takes the fuseki dataset url as
parameter.
Hope this helps.
Regards,
Sebastian
On 31.10.19 11:55, Andy Seaborne wrote:
Sebastian,
Do you have a complete, minimal example, including the Fuseki setup for
the user/password. Which Fuseki variant? war? full-jar? main?
Andy
PS Don't forget teh javadoc on connectPW : it's "basic auth"
On 31/10/2019 10:30, Sebastian Trueg wrote:
Hi everyone,
trying to use RDFConnection with Jena 3.13.1 to put a Model into a
remote Fuseki instance I encountered very strange behavior. First off,
let me show my very simple code:
try(RDFConnection conn
= RDFConnectionFactory.connectPW(datasetUrl, "admin", "admin")) {
conn.put(graphUri, model);
}
This works fine on its own and for very small models in general. But as
soon as I repeat the exact same snippet of code, ie. run the same try
block twice I get a SocketException (Broken pipe) on the first call to
RDFConnection::put.
So, to sum up:
- Single put works fine.
- A subsequent call to put will result in the first one already
throwing
an exception!
- Using a model with less than 100 triples results in both put
operations to succeed.
- In all this the Fuseki instance keeps on working.
Any ideas?
Regards,
Sebastian
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev;
import org.apache.jena.atlas.lib.Lib;
import org.apache.jena.atlas.web.AuthScheme;
import org.apache.jena.fuseki.jetty.JettyLib;
import org.apache.jena.fuseki.main.FusekiServer;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdfconnection.RDFConnection;
import org.apache.jena.rdfconnection.RDFConnectionFactory;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.DatasetGraphFactory;
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.UserStore;
public class Connect {
public static void main(String... args) throws Exception {
Model model = ModelFactory.createDefaultModel();
for (int i = 0; i < 100; ++i) {
model.add(model.createResource("urn:test:res" + i), RDF.type, model.createResource("urn:test:thing"));
model.add(model.createResource("urn:test:res" + i), RDFS.label, model.createLiteral("Thing " + i, "en"));
model.add(model.createResource("urn:test:subres" + i), RDF.type, model.createResource("urn:test:thing"));
model.add(model.createResource("urn:test:subres" + i), RDFS.label, model.createLiteral("Subthing " + i, "en"));
model.add(model.createResource("urn:test:res" + i), model.createProperty("urn:test:hasSubThing"), model.createResource("urn:test:subres" + i));
}
DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
UserStore userStore = new UserStore();
JettyLib.addUser(userStore, "admin", "admin");
userStore.start();
ConstraintSecurityHandler securityHandler = JettyLib.makeSecurityHandler("", userStore, AuthScheme.BASIC);
// Server level security?
FusekiServer server =
FusekiServer.create()
.auth(AuthScheme.BASIC)
.securityHandler(securityHandler)
// WARNING: needs password file to trigger setup.
.passwordFile("passwd-does-not-exist")
.add("/ds", dsg)
.build();
server.start();
try {
for ( int j = 0 ; j < 2 ; j++ ) {
try(RDFConnection conn = RDFConnectionFactory.connectPW("http://localhost:3330/ds", "admin", "admin")) {
System.out.println("Put "+j);
conn.put("urn:graphs:test", model);
}
}
} catch (Exception ex) {
ex.printStackTrace();
Lib.sleep(1000);
System.out.println("STOP");
server.stop();
}
System.exit(0);
}
}