简体   繁体   中英

Java jena fuseki set OntModelSpec pellet reasoner

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);
...
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM