Jar file is not recognized by Maven causes NoClassDefError (ALICE program ab)

218 Views Asked by At

Please read the note below.

I am having a problem in my chatbot program. I already did all the instructions they said on the tutorials of different website about how to create a chatbot in java using aiml. I create a maven project. Add the Ab.jar file in the dependency, even in local repository but still I am having this error.

Exception in thread "main" java.lang.NoClassDefFoundError: org/alicebot/ab/MagicBooleans
    at com.Chatbot.main(Chatbot.java:21)
Caused by: java.lang.ClassNotFoundException: org.alicebot.ab.MagicBooleans
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

This is the half of the code in Chatbot.java

import java.io.File;

import org.alicebot.ab.Bot;
import org.alicebot.ab.Chat;
import org.alicebot.ab.History;
import org.alicebot.ab.MagicBooleans;
import org.alicebot.ab.MagicStrings;
import org.alicebot.ab.utils.IOUtils;

public class Chatbot {
    private static final boolean TRACE_MODE = false;
    static String botName = "super";

    public static void main(String[] args) {
        try {

            String resourcesPath = getResourcesPath();
            System.out.println(resourcesPath);
            MagicBooleans.trace_mode = TRACE_MODE;
            Bot bot = new Bot("super", resourcesPath);
            Chat chatSession = new Chat(bot);
            bot.brain.nodeStats();
            String textLine = "";

It seems that my jar file is not recognized or what. Im actually new to this. Response is a great help.

Note: I have already read some of the NoClassDefError question here in stackoverflow and do what they suggest but still the problem exist.

1

There are 1 best solutions below

0
On

Did not see any solution here, so here's my solution:

I installed the Ab.jar file into my maven local repository:

mvn install:install-file -Dfile='path to jar file' -DgroupId=Ab -DartifactId=com.google -Dversion=0.0.4.3 -Dpackaging=jar -DgeneratePom=true

Then added the dependency with scope compile (default scope is compile):

<dependency>  
    <artifactId>com.google</artifactId>    
    <groupId>Ab</groupId>    
    <version>0.0.4.3</version>  
</dependency>