首先,我想说这是对我昨天发布的一个问题的跟进,我自己解决了这个问题(如何在 Maven 项目中添加 Jess?)。
这一次,轮到 Jess 在查找项目的类时遇到问题了。更具体地说,一切运行良好,直到执行 engine.batch("rules.clp") 的第一行,我得到一个“类未找到异常”。
(import cz.cuni.amis.pogamut.ut2004.examples.huntbot)
(deftemplate HunterBot (declare (from-class HunterBot)))
包结构为:
-cz.cuni.amis.pogamut.ut2004.examples.huntbot
-- HunterBot.java
下面是 HunterBot.java 文件的第一行:
package cz.cuni.amis.pogamut.ut2004.examples.huntbot;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import jess.*;
import cz.cuni.amis.introspection.java.JProp;
import cz.cuni.amis.pogamut.base.agent.navigation.IPathExecutorState;
import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.EventListener;
import cz.cuni.amis.pogamut.base.utils.Pogamut;
import cz.cuni.amis.pogamut.base.utils.guice.AgentScoped;
import cz.cuni.amis.pogamut.base.utils.math.DistanceUtils;
import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
import cz.cuni.amis.pogamut.ut2004.agent.module.utils.TabooSet;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004PathAutoFixer;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004DistanceStuckDetector;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004PositionStuckDetector;
import cz.cuni.amis.pogamut.ut2004.agent.navigation.stuckdetector.UT2004TimeStuckDetector;
import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController;
import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
import cz.cuni.amis.pogamut.ut2004.communication.messages.UT2004ItemType;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Initialize;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Move;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Rotate;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Stop;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.StopShooting;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotDamaged;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotKilled;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Item;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerDamaged;
import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerKilled;
import cz.cuni.amis.pogamut.ut2004.utils.UT2004BotRunner;
import cz.cuni.amis.utils.exception.PogamutException;
import cz.cuni.amis.utils.flag.FlagListener;
import java.util.logging.Logger;
/**
* Example of Simple Pogamut bot, that randomly walks around the map searching for preys shooting at everything that is in its way.
*
* @author Rudolf Kadlec aka ik
* @author Jimmy
*/
@AgentScoped
public class HunterBot extends UT2004BotModuleController<UT2004Bot> {
Rete engine;
...
最后这是 pom.xml 文件:
<?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>
<repository>
<id>data-local</id>
<name>data</name>
<url>file://${project.basedir}/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>compile</scope>
</dependency>
</dependencies>
</project>
jess-7.1p2.jar 文件位于 (base.dir)\repo\gov\sandia\jess\7.1p2\ 。它被认为没有问题。
PS:我试图使这个问题尽可能详细。如果需要更多信息,我可以立即提供。