protegeproject / protege

Protege Desktop
http://protege.stanford.edu
Other
1.01k stars 231 forks source link

Strange "ontology already exists" error #1150

Open alanruttenberg opened 1 year ago

alanruttenberg commented 1 year ago

I received this error on an ontology I was working on, which was very confusing. I've whittled down the example to a minimal case that generates the same error. Roughly, it's two ontologies each of which imports the other, with the top ontology having a single qualified cardinality constraint is fine other than the class and property not being declared. The fact that there's a single class defined isn't the problem as in the original case it was a large ontology with no other parsing errors.

Loading top.owl gives a popup with the "ontology already exists" error, and on inspection of the log I see a parsing error for the class.

With the property declared the file opens just fine.

I'm attaching a zip with top.owl, import.owl, and catalog-v001.xml

The error is triggered when opening top.owl Minimal.zip

It's fine if Protege rejects this ontology because of the undeclared class and property, but the error thrown is confusing and made it difficult to debug what was going on. It would be helpful, at a minimum, to give the reason for the expression not parsing, namely it wasn't declared. If there's no way to avoid the "ontology already exists" error then perhaps an additional message saying to look in the error log, with perhaps some hints about what to look for would be helpful.

Error: Ontology already exists. OntologyID(OntologyIRI(<http://example.com/top.owl>) VersionIRI(<null>))

Error log:

 INFO  17:24:42  Received request to edit document at file:/Users/alanr/Desktop/Minimal/top.owl
   INFO  17:24:42  Application is initialized.  Opening URI.
   INFO  17:24:42  Creating and setting up (default) editor kit for file:/Users/alanr/Desktop/Minimal/top.owl
   INFO  17:24:42  OWL API Version: 4.5.25.2023-02-15T19:15:49Z
   INFO  17:24:42  ------------------------------- Loading Ontology -------------------------------
   INFO  17:24:42  Loading ontology from file:/Users/alanr/Desktop/Minimal/top.owl
   INFO  17:24:42  Adding folder to ontology catalog: /Users/alanr/Desktop/Minimal
   INFO  17:24:42  Imported ontology document http://example.com/import.owl was resolved to Optional[file:/Users/alanr/Desktop/Minimal/import.owl] by the ontology catalog.
   INFO  17:24:42  Imported ontology document http://example.com/top.owl was resolved to Optional[file:/Users/alanr/Desktop/Minimal/top.owl] by the ontology catalog.
  ERROR  17:24:42  Entity not properly recognized, missing triples in input? http://org.semanticweb.owlapi/error#Error83 for type Class
   INFO  17:24:42  Unparsed triple: _:genid2147483812 -> http://www.w3.org/2002/07/owl#onProperty -> http://example.com/EX_0000022
   INFO  17:24:42  Unparsed triple: _:genid2147483812 -> http://www.w3.org/2002/07/owl#onClass -> http://example.com/EX_0000041
   INFO  17:24:42  Finished loading imported ontology at file:/Users/alanr/Desktop/Minimal/top.owl
   INFO  17:24:42  Finished loading imported ontology at file:/Users/alanr/Desktop/Minimal/import.owl
  ERROR  17:24:42  Entity not properly recognized, missing triples in input? http://org.semanticweb.owlapi/error#Error84 for type Class
   INFO  17:24:42  Unparsed triple: _:genid2147483814 -> http://www.w3.org/2002/07/owl#onProperty -> http://example.com/EX_0000022
   INFO  17:24:42  Unparsed triple: _:genid2147483814 -> http://www.w3.org/2002/07/owl#onClass -> http://example.com/EX_0000041
  ERROR  17:24:42  OWLOntologyManagerImpl.checkForOntologyIDChange() existing:Ontology(OntologyID(OntologyIRI(<http://example.com/top.owl>) VersionIRI(<null>))) [Axioms: 3 Logical Axioms: 1] First 20 axioms: {AnnotationAssertion(owl:qualifiedCardinality _:genid2147483813 "1"^^xsd:nonNegativeInteger) Declaration(Class(<http://example.com/EX_0000034>)) SubClassOf(<http://example.com/EX_0000034> <http://org.semanticweb.owlapi/error#Error83>)}
  ERROR  17:24:42  OWLOntologyManagerImpl.checkForOntologyIDChange() new:Ontology(OntologyID(Anonymous-312)) [Axioms: 3 Logical Axioms: 1] First 20 axioms: {AnnotationAssertion(owl:qualifiedCardinality _:genid2147483815 "1"^^xsd:nonNegativeInteger) SubClassOf(<http://example.com/EX_0000034> <http://org.semanticweb.owlapi/error#Error84>) Declaration(Class(<http://example.com/EX_0000034>))}
  ERROR  17:24:42  OWLOntologyManagerImpl.checkForOntologyIDChange() only in existing:[SubClassOf(<http://example.com/EX_0000034> <http://org.semanticweb.owlapi/error#Error83>)]
  ERROR  17:24:42  OWLOntologyManagerImpl.checkForOntologyIDChange() only in new:[SubClassOf(<http://example.com/EX_0000034> <http://org.semanticweb.owlapi/error#Error84>)]
   INFO  17:24:42  Finished loading file:/Users/alanr/Desktop/Minimal/top.owl
   WARN  17:24:42  Ontology already exists. OntologyID(OntologyIRI(<http://example.com/top.owl>) VersionIRI(<null>))
org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException: Ontology already exists. OntologyID(OntologyIRI(<http://example.com/top.owl>) VersionIRI(<null>))
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1253) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1200) ~[na:na]
    at org.protege.editor.owl.model.io.OntologyLoader.loadOntologyInternal(OntologyLoader.java:124) ~[na:na]
    at org.protege.editor.owl.model.io.OntologyLoader.lambda$loadOntologyInOtherThread$0(OntologyLoader.java:71) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:na]
    at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
Caused by: org.semanticweb.owlapi.model.OWLOntologyRenameException: Could not rename ontology. An ontology with this ID already exists: OntologyID(OntologyIRI(<http://example.com/top.owl>) VersionIRI(<null>)) change: SetOntologyIDData(OntologyID(OntologyIRI(<http://example.com/top.owl>) VersionIRI(<null>)))
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.checkForOntologyIDChange(OWLOntologyManagerImpl.java:882) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.enactChangeApplication(OWLOntologyManagerImpl.java:642) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.applyChanges(OWLOntologyManagerImpl.java:670) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.applyChange(OWLOntologyManagerImpl.java:820) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer.applyChange(OWLRDFConsumer.java:733) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer.chooseAndSetOntologyIRI(OWLRDFConsumer.java:1492) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer.endModel(OWLRDFConsumer.java:1393) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFParser.parse(RDFParser.java:152) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:71) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:220) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.actualParse(OWLOntologyManagerImpl.java:1303) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1243) ~[na:na]
    ... 7 common frames omitted
matthewhorridge commented 1 year ago

Thanks very much for the minimal test case. I've reproduced this.

doriantaylor commented 1 year ago

I also got this just now trying to load https://vocab.methodandstructure.com/intertwingler#