0

I get this error message

Error starting application: Error creating query engine Drools. Exception: java.lang.NoSuchMethodError. Message: 'void org.semanticweb.owlapi.util.PriorityCollection.add(java.io.Serializable)'

I am using SWRL API for Java to run SQWRL queries engine on OWL ontologies. So, I built edu.stanford.swrl swrlapi-example from Maven swrl API and swrlapi-drools-engine :2.1.0 . owlApi: :owlapi-osgidistribution 5.1.9

OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();

        OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
        OWLOntology ontology = ontologyManager.loadOntologyFromOntologyDocument
                (new File("Ontologies\\MFPO.owl"));
        System.out.println("ontology has loaded successfully ");
        // Create SQWRL query engine using the SWRLAPI

        SQWRLQueryEngine queryEngine = SWRLAPIFactory.createSQWRLQueryEngine(ontology);


        // Create a rule engine for mined rules
        SWRLRuleEngine ruleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology);

        System.out.println("swrl rule engine created successfully");

then i get this message (catched in runtime exception) Error creating query engine Drools. Exception: java.lang.NoSuchMethodError. Message: 'boolean org.semanticweb.owlapi.model.OWLDocumentFormat.isPrefixOWLOntologyFormat()'

FidmeD31
  • 1
  • 2
  • SWRL API does depend on OWL API v4, you used OWL API v5 - that does **not** work, you have to use v4 as dependency – UninformedUser Jun 05 '23 at 14:14
  • To add to the previous comment: you have two OWLAPI versions in your classpath. This is causing code relying on one version (OWLManager, I believe) to throw an error because the class loader is giving it a PriorityCollection class from the other version. – Ignazio Jun 06 '23 at 07:47
  • thanks @UninformedUser ,and ignazio but when i tried owlapi-osgidistribution V4.3.1 i get this error "Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError com.google.inject.internal.cglib.reflect.$FastClass$Generator.getProtectionDomain(FastClass.java:73)" so i cant load my owl ontology in java project – FidmeD31 Jun 06 '23 at 08:13
  • Thanks i fixed that , i used owl api osgidisV4 and swrl/sqwl Api 2.1.0 but i find out that the drools api was the reason of a conflict in maven dependency (the hell Xd) so i used a final stable version – FidmeD31 Jun 08 '23 at 23:04

0 Answers0