0

I am encountering a problem with my java application.

I'm trying to proceed requests on a Fuseki server to get response from an ontology loaded on it.

On my fifth request, the server block and doesn't return any response and sometimes i get this error

AVERTISSEMENT: The web application [MiCorr-WebServices] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. Stack trace of request processing thread:[

sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)

I've tried to inverse the queries to see if the problem becomes from a query but the results are the same.

Do someone can help me to find a solution to this problem. You can see my java classes that i use to query the fuseki server. I'm not really sure on it but i get good results for the 4 first queries.

public class OntologyService {

private Artefacts artefacts;

private List<QuerySolution> querySolutionList;

private RDFConnectionRemoteBuilder builder;

private OntologyQuery query;

public OntologyService() {
    // - Création de la connexion sur le serveur Fuseki
    builder = RDFConnectionFuseki.create().destination("http://localhost:8080/MiCorrDS/")
            .gspEndpoint("MiCorrGraph");

    RDFConnectionFuseki conn = (RDFConnectionFuseki) builder.build();

    query = new OntologyQuery(conn);
    artefacts = new Artefacts();

}

public Artefacts getResearchProperties(String text, String country, String metalFamily, String corrosionForms,
        String environments) {

    querySolutionList = new ArrayList<>();

    // - Recherche si le texte saisi existe dans l'ontologie
    querySolutionList = query.getPropertiesDataQuery(text);

    if (!querySolutionList.isEmpty()) {

        QuerySolution artefact = (QuerySolution) querySolutionList.get(0);

        artefacts.setText(artefact.getLiteral("?artefactName").getString());
        artefacts.setTextId(artefact.getLiteral("?artefactId").getInt());
        artefacts.setTextType(artefact.getResource("?artefactType").getLocalName());

    } else {

        artefacts.setText("");
        artefacts.setTextId(0);
        artefacts.setTextType("");

    }

    // - Recherche si le pays saisi existe dans l'ontologie
    querySolutionList = query.getPropertiesDataQuery(country);

    if (!querySolutionList.isEmpty()) {

        QuerySolution artefact = (QuerySolution) querySolutionList.get(0);

        artefacts.setCountry(artefact.getLiteral("?artefactName").getString());
        artefacts.setCountryId(artefact.getLiteral("?artefactId").getInt());
        artefacts.setCountryType(artefact.getResource("?artefactType").getLocalName());

    } else {

        artefacts.setCountry("");
        artefacts.setCountryId(0);
        artefacts.setCountryType("");

    }

    // - Recherche si le famille du métal saisie existe dans l'ontologie
    querySolutionList = query.getPropertiesDataQuery(metalFamily);

    if (!querySolutionList.isEmpty()) {

        QuerySolution artefact = (QuerySolution) querySolutionList.get(0);

        artefacts.setMetalFamily(artefact.getLiteral("?artefactName").getString());
        artefacts.setMetalFamilyId(artefact.getLiteral("?artefactId").getInt());
        artefacts.setMetalFamilyType(artefact.getResource("?artefactType").getLocalName());

    } else {

        artefacts.setMetalFamily("");
        artefacts.setMetalFamilyId(0);
        artefacts.setMetalFamilyType("");

    }

    // - Recherche si la forme de corrosion saisie existe dans l'ontologie
    querySolutionList = query.getPropertiesDataQuery(corrosionForms);

    if (!querySolutionList.isEmpty()) {

        QuerySolution artefact = (QuerySolution) querySolutionList.get(0);

        artefacts.setCorrosionForms(artefact.getLiteral("?artefactName").getString());
        artefacts.setCorrosionFormsId(artefact.getLiteral("?artefactId").getInt());
        artefacts.setCorrosionFormsType(artefact.getResource("?artefactType").getLocalName());

    } else {

        artefacts.setCorrosionForms("");
        artefacts.setCorrosionFormsId(0);
        artefacts.setCorrosionFormsType("");

    }

    // - Recherche si l'environnement saisi existe dans l'ontologie
    querySolutionList = query.getPropertiesDataQuery(environments);

    if (!querySolutionList.isEmpty()) {

        QuerySolution artefact = (QuerySolution) querySolutionList.get(0);

        artefacts.setEnvironments(artefact.getLiteral("?artefactName").getString());
        artefacts.setEnvironmentsId(artefact.getLiteral("?artefactId").getInt());
        artefacts.setEnvironmentsType(artefact.getResource("?artefactType").getLocalName());

    } else {

        artefacts.setEnvironments("");
        artefacts.setEnvironmentsId(0);
        artefacts.setEnvironmentsType("");

    }

    // - Recherche si le famille du métal saisie existe dans l'ontologie
    querySolutionList = query.getPropertiesDataQuery(corrosionForms);

    if (!querySolutionList.isEmpty()) {

        QuerySolution artefact = (QuerySolution) querySolutionList.get(0);

        artefacts.setCorrosionForms(artefact.getLiteral("?artefactName").getString());
        artefacts.setCorrosionFormsId(artefact.getLiteral("?artefactId").getInt());
        artefacts.setCorrosionFormsType(artefact.getResource("?artefactType").getLocalName());

    } else {

        artefacts.setCorrosionForms("");
        artefacts.setCorrosionFormsId(0);
        artefacts.setCorrosionFormsType("");

    }

    return artefacts;
}

}

And the query class

public class OntologyQuery {

private static final String FILENAME1 = "C:\\DEV\\SPARQL\\micorr_query1.txt";

private static final boolean CONSOLE_LOG = true;

private RDFConnectionFuseki conn;

public OntologyQuery(RDFConnectionFuseki remoteConn) {
    conn = remoteConn;
}

public List<QuerySolution> getPropertiesDataQuery(String text) {
    String sparqlRequest = readFileToString(FILENAME1);

    sparqlRequest = sparqlRequest.replaceAll("%text%", text);

    System.out.println(sparqlRequest);

    Query query = QueryFactory.create(sparqlRequest);

    List<QuerySolution> list = null;

    // In this variation, a connection is built each time.
    if(CONSOLE_LOG) {

        conn.queryResultSet(query, ResultSetFormatter::out);

    }
    list = ResultSetFormatter.toList(conn.query(query).execSelect());

    return list;
}

private static String readFileToString(String filename) {

    StringBuilder sb = new StringBuilder();

    try (BufferedReader br = new BufferedReader(new FileReader(filename))) {

        String sCurrentLine;

        while ((sCurrentLine = br.readLine()) != null) {
            sb.append(sCurrentLine);
            sb.append(" ");
        }

    } catch (IOException e) {
        e.printStackTrace();
    }

    return sb.toString();
}

}

And here is the SPARQL query

PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl:<http://www.w3.org/2002/07/owl#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX vocab:<http://micorr.ig.he-arc.ch/vocab#>
PREFIX ont: <http://www.co-ode.org/ontologies/ont.owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?artefact ?artefactId ?artefactType ?artefactName
FROM <http://localhost:8080/MiCorrDS/data/MiCorrGraph>
WHERE {
    ?artefact a ?artefactType .
    ?artefact rdfs:label "%text%" .
    BIND(IRI(CONCAT(STR(?artefactType), "_id")) AS ?iriConcat)
    BIND("%text%" AS ?artefactName)
    ?artefact ?iriConcat ?artefactId .
    FILTER( STRSTARTS(str(?artefactType), "http://micorr.ig.he-arc.ch/vocab")     )
  }

Thanks for your help.

TallTed
  • 9,069
  • 2
  • 22
  • 37
j_schneider
  • 65
  • 1
  • 10
  • Which version of Fuseki? And you are using Tomcat? Have you tried with `RDFConnectionRemote` as your usage is not especially Fuseki-specific. There doesn't appear to be anything wrong - if you have an example that is specific to the problem encountered (without the application related operations), that would be helpful. https://stackoverflow.com/help/mcve – AndyS Jul 09 '18 at 13:16
  • The fuseki version is 3.6.0 and I'm using a Tomcat 9. It's the first version of my java application so if it's better to use `RDFConnectionRemote` I'll try. – j_schneider Jul 09 '18 at 13:56
  • `FROM <...>` - If you mean to access that graph with the query, then `GRAPH <>` is the better way. `WHERE { GRAPH <...> { ?artefact ... } }`. – AndyS Jul 09 '18 at 20:30
  • I change my query but nothing change on my application. I have always the same problem – j_schneider Jul 12 '18 at 12:43

0 Answers0