0

spring Boot project gives me No message available, null output! i know this error means i have an issue with my code but i am so new to the ontologies and TDB so please help! I am trying to bring all the individualsfrom my rdf file and store it in TDB and i can't find helpful answer!

Example.java

public class Example {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

ExampleController.java

@RestController
public class ExampleController {

    File file;
    Model model;
    InfModel infModel;
    Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
    Dataset dataset;
    QueryExecution qe;

    @RequestMapping("/getAll")
    public List getAllIndiv() { 
        List list = new ArrayList();
        try {
              String directory = "tdb" ;
               dataset = TDBFactory.createDataset(directory) ;
               dataset.begin(ReadWrite.READ) ;
              String uri ="http://example#";
              model = dataset.getNamedModel(uri);
              String source = "example.owl";
              FileManager.get().readModel(model, source);
            String a = "";
            String queryString = "\r\n"
                    + "PREFIX ns: <http://example#>"
                    + "PREFIX rdf: <http://example-syntax-ns#>" + "SELECT ?Individuals " + "WHERE {"
                    + "?Individuals rdf:type ns:Concept." + "}";
            Query query = QueryFactory.create(queryString);
            query.getQueryPattern();
             qe = QueryExecutionFactory.create(query, dataset);
            ResultSet results = qe.execSelect();
            ResultSetFormatter.out(results);
            while (results.hasNext()) {
                QuerySolution result = (results.next());
                RDFNode ind = result.get("Individuals");
                a = ind.asResource().getLocalName() + "";
                list.add(a);
            qe.close();
            }
            return list;
        } catch (Exception e) {
            e.printStackTrace();
        }finally {

            if(model != null && dataset != null) {
                qe.close();
                dataset.commit();            
                model.close();
              dataset.end();
            }
        }
        return null;
    }   
}
H. H
  • 103
  • 9
  • base on your code it is difficult to know the issue, did you check the configuration? does your error like below link: https://stackoverflow.com/questions/38205761/spring-boot-no-message-available-errorstatus-404/38208372 – tiepvut Nov 04 '19 at 15:28
  • @tiepvut thank you for replying, i did but still not fixing the answer – H. H Nov 04 '19 at 15:36
  • @tiepvut no, not the same error! just java.lang.NullPointerException: null and the status = 500 (server error ) – H. H Nov 04 '19 at 15:39

0 Answers0