I'm getting the following error while running a query from Java with RDF4J on an EC2 server (it works fine locally).
java_1 | 30-Aug-2019 13:51:50.511 SEVERE [http-nio-8080-exec-1] com.sun.jersey.spi.container.ContainerResponse.mapMappableContainerException The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java_1 | org.eclipse.rdf4j.repository.http.HTTPQueryEvaluationException: Failed to get server protocol; no such resource on this server: http://127.0.0.1:8080/openrdf-sesame/protocol
java_1 | at org.eclipse.rdf4j.repository.http.HTTPTupleQuery.evaluate(HTTPTupleQuery.java:56)
The relevant Java code:
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.query.BindingSet;
import org.eclipse.rdf4j.query.QueryLanguage;
import org.eclipse.rdf4j.query.TupleQuery;
import org.eclipse.rdf4j.query.TupleQueryResult;
import org.eclipse.rdf4j.RDF4JException;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.http.HTTPRepository;
public void test() throws RDF4JException
{
String sesameServer ="http://127.0.0.1:8080/rdf4j-server";
HTTPRepository db = new HTTPRepository(sesameServer, repositoryID);
db.initialize();
try (RepositoryConnection conn = db.getConnection()) {
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
}
catch(RDF4JException e) {
System.out.println(e.getMessage());
}
finally {
db.shutDown();
}
}
I've tried changing the IP in sesameServer to the server's public IP and the same error is thrown. Regardless, this is running on the same server (Tomcat 8) as the RDF database so 127.0.0.1 should work (and does work locally).
Any help/ideas greatly appreciated.
Thanks to Jeen Broekstra for the help. The Java constants file which held the server url as a variable wasn't being built on Docker/EC2, so an old version of the java class file (which still pointed to sesame) was being used. Rebuilding it fixed everything.