Sreekar
Sreekar

Reputation: 43

Error in creating rule engine drools

I intended to use the Openllet reasoner, as suppose to the other available reasoners. But this reasoner is compatible only with the OWL API 5.X.X distribution. I have a xxx.owl file which contains SWRL rules. Since the existing SWRL API is not compatible with OWL API 5, Ignazio Palmisano had kindly put up a forked repository with required changes, so that it is compatible with the OWL API 5.X.X distribution. Consequently, I removed the dependencies related to SWRL API and drools engine. Instead, I built them locally by downloading the 'zip' files.

Now, with ".jar" files of the SWRL API and Drools loaded into the project in intelliJ, I am presented with this following error:

Exception in thread "main" org.swrlapi.exceptions.SWRLRuleEngineException: Error creating rule engine Drools. Exception: java.lang.NoClassDefFoundError. Message: org/drools/runtime/rule/AgendaFilter
    at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:71)
    at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:41)
    at org.swrlapi.factory.SWRLAPIFactory.createSWRLRuleEngine(SWRLAPIFactory.java:38)
    at SWRLrules.main(SWRLrules.java:61)

Caused by: java.lang.NoClassDefFoundError: org/drools/runtime/rule/AgendaFilter
    at org.swrlapi.drools.core.DroolsSWRLRuleEngineCreator.create(DroolsSWRLRuleEngineCreator.java:27)
    at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:59)
    ... 3 more

Caused by: java.lang.ClassNotFoundException: org.drools.runtime.rule.AgendaFilter
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 5 more code here

Here I am also attaching the dependencies in pom.xml file:

<dependencies>

    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>owlapi-osgidistribution</artifactId>
        <version>5.1.4</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
    </dependency>
    <dependency>
        <groupId>com.github.galigator.openllet</groupId>
        <artifactId>openllet-owlapi</artifactId>
        <version>2.6.3</version>
    </dependency>

</dependencies>

<build>

    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>org.swrlapi.example.SWRLAPIExample</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>org.swrlapi.example.SWRLAPIExample</mainClass>
            </configuration>
        </plugin>

    </plugins>

</build>

P.S: I built the swrl api and drools engine locally and imported the jar file into the project.

Upvotes: 1

Views: 838

Answers (1)

Ignazio
Ignazio

Reputation: 10659

You do not need to remove the dependencies from the pom file (the error you're seeing is caused by some jar having been missed in the manual process).

If you use my swrlapi fork and change the version to, say, 2.0.6-SNAPSHOT, then running locally

mvn clean install

will put a 2.0.6-SNAPSHOT jar in your local maven repository. At that point, change your pom to require swrlapi 2.0.6-SNAPSHOT and you'll get the updated version in your application.

Upvotes: 2

Related Questions