Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error starting application: Error creating query engine Drools #9

Open
MRNaqvi opened this issue Mar 21, 2020 · 0 comments
Open

Error starting application: Error creating query engine Drools #9

MRNaqvi opened this issue Mar 21, 2020 · 0 comments

Comments

@MRNaqvi
Copy link

MRNaqvi commented Mar 21, 2020

package swrlApi;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.swrlapi.builtins.AbstractSWRLBuiltInLibrary;

import org.swrlapi.builtins.SWRLBuiltInLibraryManager;
import org.swrlapi.factory.SWRLAPIFactory;
import org.swrlapi.parser.SWRLParseException;
import org.swrlapi.sqwrl.SQWRLQueryEngine;
import org.swrlapi.sqwrl.SQWRLResult;
import org.swrlapi.sqwrl.exceptions.SQWRLException;

import java.io.File;
import java.util.Optional;

public class APIEXAMPLE {

public static void main(String[] args) {
	
	
	
	// TODO Auto-generated method stub
	
	
	

	    try {
	      // Create an OWL ontology using the OWLAPI
	    	OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
	    	 OWLOntology ontology= ontologyManager.loadOntologyFromOntologyDocument(new File("./src/ontology.txt")); 
		       
		       
		    
		 
	        System.out.println("Loaded ontology: " + ontology);
	      // Create SQWRL query engine using the SWRLAPI
	      SQWRLQueryEngine queryEngine = SWRLAPIFactory.createSQWRLQueryEngine(ontology);
	    
	      SQWRLResult result = queryEngine.runSQWRLQuery("Q1", 
	    		   "Person(?p) ^ hasName(?p, ?name) ^ hasSalary(?p, ?salary)" +
	    		   " -> sqwrl:select(?name, ?salary)");
	     
	    		 
	    		 // Process the results of the SQWRL query
	    		 while (result.next()) {
	    		   System.out.println("Name: " + result.getLiteral("name").getString());
	    		   System.out.println("Salary: " + result.getLiteral("salary").getInteger());
	      // Process the SQWRL result
	    		 }
	    		 }  catch (OWLOntologyCreationException e) {
	      System.err.println("Error creating OWL ontology: " + e.getMessage());
	      System.exit(-1);
	    } catch (SWRLParseException e) {
	      System.err.println("Error parsing SWRL rule or SQWRL query: " + e.getMessage());
	      System.exit(-1);
	    } catch (SQWRLException e) {
	      System.err.println("Error running SWRL rule or SQWRL query: " + e.getMessage());
	      System.exit(-1);
	    } catch (RuntimeException e) {
	      System.err.println("Error starting application: " + e.getMessage());
	      System.exit(-1);
	    }
	  }

	

}

Error starting application: Error creating query engine Drools. Exception: org.swrlapi.exceptions.SWRLAPIException. Message: Could not loadExternalSWRLBuiltInLibraries class loader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant