ClassNotFoundException in Minecraft plugin coded with visual studio code in maven

I made a jar file including some code that is useable for me to create minecraft plugins and wanted to make a local repository to the other file, which is called lavidefaultlib-1.3.jar.
The lavidefaultlib is stacked on a different path, both java programs are on D:/.
Everytime I try to start the minecraft server, that has the plugin on it just says it cannot find the class. The Error message of the server looks like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>java.lang.NoClassDefFoundError: com/lavi/GameMode/SPLi_GameMode
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) ~[?:?]
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:206) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:117) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?]
at com.Lavi.Init.FileInit.onEnable(FileInit.java:30) ~[?:?]
at com.Lavi.SPLi_Main_Main.onEnable(SPLi_Main_Main.java:31) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:267) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:492) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_21_R1.CraftServer.enablePlugin(CraftServer.java:575) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
at org.bukkit.craftbukkit.v1_21_R1.CraftServer.enablePlugins(CraftServer.java:489) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:641) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:426) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:269) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1017) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.lang.ClassNotFoundException: com.lavi.GameMode.SPLi_GameMode at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:160) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] ... 21 more
</code>
<code>java.lang.NoClassDefFoundError: com/lavi/GameMode/SPLi_GameMode at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[?:?] at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) ~[?:?] at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[?:?] at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:206) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593) ~[?:?] at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:117) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at com.Lavi.Init.FileInit.onEnable(FileInit.java:30) ~[?:?] at com.Lavi.SPLi_Main_Main.onEnable(SPLi_Main_Main.java:31) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:267) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:492) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_21_R1.CraftServer.enablePlugin(CraftServer.java:575) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded] at org.bukkit.craftbukkit.v1_21_R1.CraftServer.enablePlugins(CraftServer.java:489) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded] at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:641) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded] at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:426) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded] at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:269) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded] at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1017) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded] at java.base/java.lang.Thread.run(Thread.java:1583) [?:?] Caused by: java.lang.ClassNotFoundException: com.lavi.GameMode.SPLi_GameMode at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:160) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] ... 21 more </code>
java.lang.NoClassDefFoundError: com/lavi/GameMode/SPLi_GameMode
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) ~[?:?]
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[?:?]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:206) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593) ~[?:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:117) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?]
    at com.Lavi.Init.FileInit.onEnable(FileInit.java:30) ~[?:?]
    at com.Lavi.SPLi_Main_Main.onEnable(SPLi_Main_Main.java:31) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:267) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:492) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_21_R1.CraftServer.enablePlugin(CraftServer.java:575) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
    at org.bukkit.craftbukkit.v1_21_R1.CraftServer.enablePlugins(CraftServer.java:489) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:641) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:426) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
    at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:269) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
    at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1017) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4306-Spigot-a759b62-bd8aded]
    at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.lang.ClassNotFoundException: com.lavi.GameMode.SPLi_GameMode at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:160) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] ... 21 more

The class com.lavi.GameMode.SPLi_GameMode shold be the class in my lavidefaultlib.
The com.Lavi.SPLi_Main_Main file is the Main file of my minecraft plugin.
Both java projects have a POM file and are compileable.

In the MainMinecraft plugin (not the lavidefaultlib) I used the default spigot resository and my own one that shold refer to the file:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><repository>
<id>lavilib</id>
<url>file://D:/Minecraft/MinecraftPlugins/LaviDefault/lavidefaultlib/target/</url>
</repository>
</code>
<code><repository> <id>lavilib</id> <url>file://D:/Minecraft/MinecraftPlugins/LaviDefault/lavidefaultlib/target/</url> </repository> </code>
<repository>
    <id>lavilib</id>
    <url>file://D:/Minecraft/MinecraftPlugins/LaviDefault/lavidefaultlib/target/</url>
</repository>

I also placed a <dependency>

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><groupId>..</groupId>
<artifactId>Lavidefaultlib</artifactId>
<version>1.3</version>
<scope>provided</scope>
</code>
<code><groupId>..</groupId> <artifactId>Lavidefaultlib</artifactId> <version>1.3</version> <scope>provided</scope> </code>
<groupId>..</groupId>
<artifactId>Lavidefaultlib</artifactId>
<version>1.3</version>
<scope>provided</scope>

I do neighter know wether the dependency nor the repository makes sense. I looked for many things on the internet, but most of them desribed different solutions and none of them worked on my problem. Also the answers I found were eighter not for minecraft plugins or not with maven, it seems like it works diffrent here.

How the code of the main minecraft plugin looks (Simplified, only important parts for the problem are included):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>package com.Lavi.Init;
import com.lavi.SPLi_Main_Main;
public class FileInit { //This Class is my init class, it should initialiye the lavidefaultlib using a static method
public static void onEnable(JavaPlugin ThePlugin) { //This method gets called by my minecraft plugin while initializing
SPLi_Main_Main.onEnable(ThePlugin); //This is the call of the init method of lavidefaultlib onEnable (This produces the exyeption, that the class SPLi_Main_Main is not found)
}
}
</code>
<code>package com.Lavi.Init; import com.lavi.SPLi_Main_Main; public class FileInit { //This Class is my init class, it should initialiye the lavidefaultlib using a static method public static void onEnable(JavaPlugin ThePlugin) { //This method gets called by my minecraft plugin while initializing SPLi_Main_Main.onEnable(ThePlugin); //This is the call of the init method of lavidefaultlib onEnable (This produces the exyeption, that the class SPLi_Main_Main is not found) } } </code>
package com.Lavi.Init;

import com.lavi.SPLi_Main_Main;

public class FileInit { //This Class is my init class, it should initialiye the lavidefaultlib using a static method

    public static void onEnable(JavaPlugin ThePlugin) {      //This method gets called by my minecraft plugin while initializing
       
        SPLi_Main_Main.onEnable(ThePlugin);    //This is the call of the init method of lavidefaultlib onEnable (This produces the exyeption, that the class SPLi_Main_Main is not found)
    }
}

Your code has multiple issues, which are against spigot’s documentation.

The spigot onEnable() method isn’t like that

In your plugin.yml file (Documentation), you should put the direction to your main class. This main class should extends JavaPlugin. It’s not a static call but an instance one. If you don’t know what is static, check here.

So, your class will more be like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>package com.Lavi.init;
import com.lavi.SPLi_Main_Main;
public class FileInit extends JavaPlugin {
@Override
public void onEnable() {
SPLi_Main_Main.onEnable(this); // this = the actual object
}
}
</code>
<code>package com.Lavi.init; import com.lavi.SPLi_Main_Main; public class FileInit extends JavaPlugin { @Override public void onEnable() { SPLi_Main_Main.onEnable(this); // this = the actual object } } </code>
package com.Lavi.init;

import com.lavi.SPLi_Main_Main;

public class FileInit extends JavaPlugin {

    @Override
    public void onEnable() {
        SPLi_Main_Main.onEnable(this); // this = the actual object
    }
}

The this parameter refer to the instance of the actual “FileInit”

Running on spigot

On your maven project, you are importing a file. This file is used to compile, but it’s not included in the built file. You have to put the file imported on your server (mostly if the other file is another plugin), or you have to shade it with maven shade plugin.

Convention

In general, the package is com/fr/de/io/etc.pseudo/enterprise/etc.projectname. I think you project is not called “Init”. Also, to easily find what is the package or not, we write all package as lower case, start class with an upper case (you did it), don’t use _ for class names etc.

It’s the Camel Case.

It’s a suggestion. It’s easier to others readers (and even you in few months/years) to understand the code, but it’s not necessary.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật