ConversionException to an OntClass?

191 views Asked by At

I'm having trouble with OntClass.listSubClasses. I'm using this method in a loop, which works fine until a given point:

for(Iterator i = class.listSubClasses() ; i.hasNext() ;) {
    System.out.println(((OntClass) i.next()).getLocalName());
}

Then, the following exception shows up:

Exception in thread "main" org.apache.jena.ontology.ConversionException: Cannot convert node http://titan.be/axis-csrm/interoperabilitymodel/ontology/0.4#AXE to OntClass: it does not have rdf:type owl:Class or equivalent
    at org.apache.jena.ontology.impl.OntClassImpl$1.wrap(OntClassImpl.java:82)
...
org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
    at rocks.novateam.axis.sow.poc.backend.ontology.RegisterManager.main(RegisterManager.java:194)

which is weird.

In the ontology, here is the definition of this particular class:

<!-- http://titan.be/axis-csrm/interoperabilitymodel/ontology/0.4#AXE -->

    <rdf:Description rdf:about="http://titan.be/axis-csrm/interoperabilitymodel/ontology/0.4#AXE">
        <rdfs:subClassOf rdf:resource="http://titan.be/axis-csrm/datamodel/ontology/0.4#Register"/>
    </rdf:Description>

This is in a datamodel.owl file, which is the one in the OntModel I'm using.

<!-- http://titan.be/axis-csrm/interoperabilitymodel/ontology/0.4#AXE -->

<owl:Class rdf:about="http://titan.be/axis-csrm/interoperabilitymodel/ontology/0.4#AXE">
    <rdfs:subClassOf rdf:resource="http://titan.be/axis-csrm/interoperabilitymodel/ontology/0.4#Entity"/>
    <rdfs:label xml:lang="en">Autonomous eXchange Entity</rdfs:label>
</owl:Class>

This is in a interoperabilitymodel.owl, which is imported in the first ontology.

This import mechanism does not seem to be the problem, because there are other classes imported that way from the same ontology which do not cause the program to crash.

Any idea?

2

There are 2 answers

0
Richard-Degenne On BEST ANSWER

So, in the end, this issue had to do with Jena's OntModel strictness. Setting in to non-strict mode solved the issue.

2
ChristophE On

Isn't it so that tyour #AXE simply is not defined as OWL class?

It is a rdfs:subclassof so it must be a rdfs:class but that does not entail that it is also an owl:class