-1

the following code is used to send rdf data to a sparql endpoint.

It has worked fine until i've tried to add a reasoner to the OntoModel.

Now the compiler says: "cannot convert from com.hp.hpl.jena.ontology.OntModelspec to org.apache.jena.ontology.OntModelSpec".

So my question is, what i have to edit to let it works? (I know that the problem is obviusly in "PelletReasonerFactory.THE_SPEC" which is not from com.hp.hpl..., so is there something similar to this one, which also come from org.apache.jena... ?)

package services;

import org.apache.jena.query.DatasetAccessor;
import org.apache.jena.query.DatasetAccessorFactory;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.query.ResultSetFormatter;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.ontology.OntModel;
import org.mindswap.pellet.jena.PelletReasonerFactory;
import org.apache.jena.ontology.OntModelSpec;

class FusekiExample {

    public void addRDF(File rdf, String serviceURI){
            throws IOException {

        // the next commented line is the old working version...
        //Model m = ModelFactory.createDefaultModel();

        //these lines are the modified version which doesn't work.
        OntModelSpec oms = PelletReasonerFactory.THE_SPEC;
        OntModel m = ModelFactory.createOntologyModel(oms);
...
}

1 Answers1

2

It looks like your PelletReasoner is very old and still uses the old jena libraries and not the newest one.

You need to find a newer version of your reasoner to work with the current jena or you need to work with an older jena version.

ChristophE
  • 760
  • 1
  • 9
  • 21
  • 1
    I am to stupid to find the edit button so here my extended answer. You would need to use pellet 3.0 for your program to work. See also http://stackoverflow.com/questions/36144230/how-to-correctly-import-pellet-2-3-0-in-jena-3-0-1-eclipse – ChristophE Nov 03 '16 at 13:32