1

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?

Richard-Degenne
  • 2,892
  • 2
  • 26
  • 43

2 Answers2

0

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

ChristophE
  • 760
  • 1
  • 9
  • 21
  • If this is the problem, how come it's considered as a class in protégé, and how can I change that? – Richard-Degenne Jan 03 '17 at 09:48
  • I think the error must be somewhere here: you state "This is in a interoperabilitymodel.owl, which is imported in the first ontology." Maybe this file does not get imported correctly into your OntModel – ChristophE Jan 03 '17 at 10:42
0

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

Richard-Degenne
  • 2,892
  • 2
  • 26
  • 43