1

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.

KevLoughrey
  • 281
  • 1
  • 9
  • The server URL in your code is `http://127.0.0.1:8080/rdf4j-server` but the one mentioned in the errror message says `http://127.0.0.1:8080/openrdf-sesame` (which is what the url was before Sesame renamed itself to rdf4j). Assuming you are actually running Rdf4j Server and not Sesame, the url in the code should be the correct one. I'd double-check that the code you're actually executing sets this url correctly. – Jeen Broekstra Sep 02 '19 at 06:55
  • 1
    @Jeen Broekstra Thanks for that. We started the project back with sesame, but migrated it a while back. Turns out there was a java class file not being rebuilt in Docker when it was deployed on ec2, which held the server address. – KevLoughrey Sep 05 '19 at 22:59

1 Answers1

1

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.

KevLoughrey
  • 281
  • 1
  • 9