0

First of all I want to say this is kind of a follow up of a question I posted yesterday which I solved myself (How to add Jess in Maven project?).

This time, it's Jess' turn to have problems finding the project's classes. More specifically, everything runs fine until the execution of the 1st line of engine.batch("rules.clp"), where I get a "Class not found exception".

(import cz.cuni.amis.pogamut.ut2004.examples.huntbot)
(deftemplate HunterBot (declare (from-class HunterBot)))

The package structure is:

-cz.cuni.amis.pogamut.ut2004.examples.huntbot
-- HunterBot.java

Below are the first lines of the HunterBot.java file:

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;
...

And finally this is 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>


               <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>

The jess-7.1p2.jar file is located at (base.dir)\repo\gov\sandia\jess\7.1p2\ . It is recognized without problems.

PS: I tried to make this question as detailed as possible. If more info is needed, I can provide it immediately.

Community
  • 1
  • 1
SkyPower
  • 103
  • 2
  • 13
  • 2
    Shouldn't you `(import cz.cuni.amis.pogamut.ut2004.examples.huntbot.Hunterbot)`? In Java usually you should specify the class(and method) name or import with `.*`. – Gábor Bakos Jan 24 '15 at 12:08

1 Answers1

1

The import function permits both for importing a single class or all classes in a package. A package alone can't be imported - it doesn't make sense.

(import some.pack.SomeClass)

and

(import another.pack.*)

If you need access to the static members of a class you must use the specific form. The statics are then available as if they were a user function:

(SomeClass.MAX_NUMBER_OF_X)
laune
  • 31,114
  • 3
  • 29
  • 42