0
votes

I downloaded OWL API maven project and opened OWL API Default Implementation. I just want to load an ontology but it gives me an error.

public static final IRI example_iri2 = IRI.create("http://mged.sourceforge.net/ontologies/MGEDOntology.owl");

public static void main(String[] arg) throws OWLOntologyCreationException {
    OWLDataFactoryImpl factoryImpl = new OWLDataFactoryImpl();
    ReadWriteLock readWriteLock = new NoOpReadWriteLock();
    OWLOntologyManagerImpl managerImpl = new OWLOntologyManagerImpl(factoryImpl, readWriteLock);
    OWLOntology ontology = managerImpl.loadOntology(example_iri2);
}

The output is:

        SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    Exception in thread "main" org.semanticweb.owlapi.model.OWLOntologyFactoryNotFoundException: Could not find an appropriate factory to load ontology from ontology document: <http://mged.sourceforge.net/ontologies/MGEDOntology.owl>
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1048)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:935)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:891)
        at com.main.main.main(main.java:33)
    ------------------------------------------------------------------------
    BUILD FAILURE

How can I fix this? I tried this and it's not working.

File file = new File("pizza3.owl");
OWLOntology ontology = managerImpl.loadOntologyFromOntologyDocument(file);
1
What means downloaded? It's a Maven project, thus, it's recommended to use it via a Maven dependency. The ontology looks ok, so I guess you're missing some libraries. If you don't use Maven, you have to add all OWL API Jar files to your class path. - UninformedUser
And I suggest you to follow the OWL API examples: An OWLOntologyManager will be created via OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - UninformedUser
@AKSW no I added all dependency - NASRIN
What do you mean by import? You do you write your Java code? An IDE usually has autocompletion/import. - UninformedUser
Could you solve the issue? If yes, please provide an answer and accept it. That's how Stackoverflow is supposed to work. - UninformedUser

1 Answers

0
votes

The manager you created needs setup.

The recommended way is through OWLManager, in the apibinding module.

The recommended dependencies to use are the distribution or osgidistribution modules.