Axel M
Axel M

Reputation: 11

Java/Bukkit plugin & Fat Jar: ClassNotFoundError

I can't get my Bukkit plugin to load.

Caused by: java.lang.ClassNotFoundException: com.thestratagemmc.aikenbot.chat.ChatMessage
[20:40:59 WARN]:        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[20:40:59 WARN]:        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[20:40:59 WARN]:        at java.security.AccessController.doPrivileged(Native Method)
[20:40:59 WARN]:        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[20:40:59 WARN]:        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101)
[20:40:59 WARN]:        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86)
[20:40:59 WARN]:        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
[20:40:59 WARN]:        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
[20:40:59 WARN]:        ... 17 more

Now, I know this usually means the class doesn't exist. and ChatMessage.java is not a part of this project, I included it with maven shade.

But I know that it exists in the jar file that I am trying to load: Proof that the jar file actually contains com/thestratagemmc/aikenbot/chat/ChatMessage

This is all that ChatMessage.java is

package com.thestratagemmc.aikenbot.chat;

/**
* Created by axel on 11/29/15.
*/
public interface ChatMessage {
    public String getSender();
    public String getMessage();
    public void reply(String message);
    public void replySender(String message);
}

and this is the way it's being called

package com.thestratagemmc.aikenbot.providers.minecraft;

import com.dthielke.herochat.Channel;
import com.dthielke.herochat.ChannelChatEvent;
import com.thestratagemmc.aikenbot.chat.ChatMessage;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

/**
 * Created by axel on 11/29/15.
 */
public class MinecraftChatMessage implements ChatMessage {

public Channel channel;
public Player sender;
public String message;


public String getSender() {
    return sender.getName();
}

public String getMessage() {
    return message;
}

public MinecraftChatMessage(Channel channel, Player sender, String message) {
    this.channel = channel;
    this.sender = sender;
    this.message = message;
}

public void reply(String s) {
    synchronized (Bukkit.getServer()){
        if (channel == null) {
            sender.sendMessage(s);
        }
        else{
            channel.sendRawMessage(ChatColor.GREEN+"["+channel.getNick()+"] "+ ChatColor.WHITE + "TSMC Bot "+ChatColor.getByChar('7')+ChatColor.ITALIC+s);
        }
    }

}

public void replySender(String s) {
    synchronized(Bukkit.getServer()){
        sender.sendMessage(s);
    }
}
}

Upvotes: 0

Views: 102

Answers (2)

Axel M
Axel M

Reputation: 11

Found the issue, I just needed to restart the server...I was trying to load the plugin with /plugman reload.

Upvotes: 1

Jeremy
Jeremy

Reputation: 786

I have been making Bukkit plugins for quite a long time but this never happens to me.
It seems like your are making another plugin based on your AikenBot plugin. You have to make sure that plugin is loaded before your plugin. Add this in the plugin.yml of your plugin
depend: [MinecraftAikenBot]

Hope this helps you.

Upvotes: 0

Related Questions