How to add Jess in Maven project? [duplicate]

2019-04-16 17:40发布

问题:

This question already has an answer here:

  • Can I add jars to maven 2 build classpath without installing them? 23 answers

I have a Maven project which uses the Pogamut library (bot creation in Unreal Tournament). I want to add Jess but I am having hard time doing so. The project builds fine but I get various errors (depending on the current code inside ) when I try to run it.

Here's the pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>cz.cuni.amis.pogamut.ut2004</groupId>
        <artifactId>pogamut-ut2004-bot-pom</artifactId>
        <version>3.6.1</version>
    </parent>

    <groupId>cz.cuni.amis.pogamut.ut2004.examples</groupId>
    <artifactId>huntbot</artifactId>
    <version>3.3.1</version>
    <packaging>jar</packaging>

    <name>04-hunter-bot</name>
    <url>http://pogamut.cuni.cz</url>

    <properties>
        <bot.main.class>cz.cuni.amis.pogamut.ut2004.examples.huntbot.HunterBot</bot.main.class>
    </properties>

    <repositories>
        <repository>
            <id>amis-artifactory</id>
            <name>AMIS Artifactory</name>
            <url>http://diana.ms.mff.cuni.cz:8081/artifactory/repo</url>
        </repository>
    </repositories>



    <build>
        <plugins>
            <plugin>
                <groupId>org.dstovall</groupId>
                <artifactId>onejar-maven-plugin</artifactId>
                <version>1.4.4</version>
                <configuration>
                    <mainClass>${bot.main.class}</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

        <dependencies>

         <dependency>
          <groupId>gov.sandia</groupId>
          <artifactId>jess</artifactId>
          <version>7.1p2</version>
          <scope>system</scope>
          <systemPath>${project.basedir}/src/main/resources/jess.jar</systemPath>
         </dependency>

        </dependencies>

</project>

The Jess part is what I added myself along with some tweaks to get it working. There is a jess.jar file in the systemPath folder.

The following are inside the HunterBot.java file (the only .java source file):

import jess.*;
...
Rete engine;

No editor errors in the two above lines, everything is recognized.

Here's the exception I get when I run the project:

Exception in thread "main" PogamutException[cz.cuni.amis.pogamut.ut2004.utils.UT2004BotRunner@4891a775: Agents can't be started: com.google.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Ljess/Rete; (caused by: com.google.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Ljess/Rete;)]

回答1:

Found the solution. E L Rayle's answer helped me with it. Here it is if anyone's interested: How to include local jar files in Maven project



标签: java maven jess