Search code examples
javaeclipsetomcat7owl-api

The type OWLOntologyWalkerVisitor is not generic: Error using OWL API in Eclipse


I have a Dynamic Web Project in Eclipse 3.4 , Jsf 1.2, java 1.7, tomcat 7 and owl api 4.0. I am using example code from here in a backing bean of java. This code runs smooth in Java Application but generates error while used in JSF project and run on tomcat 7 server.

The code snippet is as follows:-

OWLOntologyWalkerVisitor<Object> visitor = new OWLOntologyWalkerVisitor<Object>(
            walker) {
            @Override
            public Object visit(OWLObjectSomeValuesFrom desc) {
            // Print out the restriction
            System.out.println(desc);
            // Print out the axiom where the restriction is used
            System.out.println(" " + getCurrentAxiom());
            System.out.println();
            // We don't need to return anything here.
            return null;
            }
            };
            // Now ask the walker to walk over the ontology structure using our
            // visitor instance.
            walker.walkStructure(visitor);

while the error it generates is:-

 The type OWLOntologyWalkerVisitor is not generic; it cannot be parameterized with arguments<Object>  

Any clue why is this happening?


Solution

  • The example code you have linked is for owlapi 3.5 (master branch). The correct example is in the version4 branch - apologies, probably a few documentation links are stale.

    Edit: version 4 Examples.java is here: https://github.com/owlcs/owlapi/blob/version4/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java

    https://github.com/owlcs/owlapi/wiki/Documentation