NoClassDefFoundError (Today is my birthday But this make me Sad)

Discussion in 'Plugin Development' started by tackleza, Apr 17, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    Hi, everyone:)

    I have problem that is My plugin error like this:
    From errorlog you will see NoClassDefFoundError and ClassNotFoundException many times and many classes

    This was an errror when I use command to start something or call my class. It's going to error when server run for long time (3-5 hour+), I think java is GC my class and can't load it back

    Example Error (This is command for my countdown system Error line 36 on pastebin)
    package com.smilekrub.smilekrubserver.commands.admin
    More countdown class (Sometime CountDownSystem error too same as on top, As I said it's random classnotfound):
    Countdown main:
    Countdown Task:
    If I restart server and I use there class in that time, everything is working fine. But if I don't use it for long time, It's become like this.

    So I need to restart server everytime to use there class, I don't know why my class is being unload (and can't load it back) <-- maybe
    Other plugins are working fine

    Any suggest?
    **Sorry for my english and grammar :p
    ***This is private plugin, I'm learning Java :)

    More information

    • Version: Craftbukkit 1.6.4 R2.0 (Recommanded Build)
    • Server Linux Centos
    • Java 7
    • Eclipse: Eclipse IDE for Java Developers
  2. Offline


    This is an interesting problem. Did you reload (but not restart) the server between starting it and the exception occurring?
    tackleza likes this.
  3. Offline


    Thank you for reply:)

    I never use "/reload" on my server, This problem happen to me every day(every 5 hour)
  4. Offline


    Hm, I was going to ask if reloading the plugin solved the problem (I suspect it would), but I don't suppose you'd know that. Anyway, I've created a StackOverflow post, since I have no idea what could be wrong and Google isn't really helping.
    tackleza likes this.
  5. Offline


    Thank you very much, Mr.Potato :)
  6. Offline


    When this occurs, are you loading the class for the first time since server startup? I would assume not, but I just want to be sure.

    Edit #1: Never mind. GCing the class is out of the question as long as the server is still running.

    Edit #2: Are the event classes a part of the plugin throwing the exception?
    tackleza likes this.
  7. Offline


    I'm not expert at Bukkit and Java but I'll expand about my server

    Server startup @ 5:00
    ... [Other player build there house]
    Server call Quicksand class and other classes (by command) @17:00

    From 5:00 to 17:00 Server didn't touch any class

    So as you ask me "are you loading the class for the first time since server startup"
    If you mean "Did system load and process there class when server startup?"

    The answer is "No"

    Server didn't touch any Quicksand and other Classes until 17:00
    So 6 hours from server startup, What happen to my class?

    Or I should run every classes when server startup? I have no diea how to fix this.
    Some time I use my Countdown class(it's working) and after that 15 min I use it again it's not work!
  8. Offline


    Sorry, I had edited my post explaining that garbage collection wasn't really a possibility anyway. In regard to your event classes, though, are they a part of the plugin throwing the exception, or a different one?

    Edit: Are you updating the JAR containing the classes you're trying to create instances of while the server is running? That would potentially cause these errors.
    tackleza likes this.
  9. Offline


    Can I pm some source code to you?
    I think it's better way to understand my code :)

    As you said create instances

    I didn't do something like

    1. Class ref = Class.forName("DemoClass");
    2. DemoClass obj = (DemoClass) ref.newInstance();
    3. //Or
    4. instance.getClass().getClassLoader().loadClass("NewClass").newInstance();
  10. Offline


    It would be better if you posted it in the thread, so that others could help you as well. I understand if you don't want to since you said it's for a private plugin, but no one has any intention of stealing it, and if you only post relevant code, there wouldn't be any point to it anyway.

    Edit: Please tag/quote me in your replies, or else I won't receive a notification about them.
    tackleza likes this.
  11. Offline


    This is quicksand command when I call class : [remove]

    Error on this command class [Line 29 on pastebin]

    QuicksandFunction : [remove]

    I never use static variable in my class so I need to do something like [remove] to get/save information about this game, If you want more information please let me know :)

    I'm new on this forums:rolleyes:
  12. Offline


    You may have more luck on the IRC channel (, as users there are able to provide immediate replies and are probably more knowledgeable in this area than I. If you need help getting to it, let me know. :)
    tackleza likes this.
  13. Offline


    Ok, I found the way how to fix this, The easiest way Move your file to new workspace And don't use dropbox to sync your classes file!

    It's still not found!
  14. Offline


    Hello and sorry for bump, But it's Classnotfound it's still I my life and I can't find solution. I try hard to search it from google. But . . . nothing
    I don't know why this problem happen to me and I can't fix it, Anyone have any idea?

    For example
    I create some countdown class and When I call it and It's error in console.

    It's said "Countdowncmd$1" not found. But when I check it in my plugin file(.jar) it's still there?
    what the ..

    It's can be class path?, I didn't set any classpath at my computer and my server, Can be?
    Or can be at "Order and Export" on Eclipse Properties of my project

    I've try to Clean and refrash my Project before Export but not work!

    Any suggest and comment are appreciate.:(
  15. Offline


    Is the version of craftbukkit you are running your server on the same version you are compiling with?
  16. Offline


    You need to show code. We have no idea what you are doing, and others that will look into this thread in the future will not get any benefit out of not being able to see what you did wrong. We are not ravenous code stealers, and I don't know any problem on this entire forum that was able to be solved without showing at least the full stack trace and at least some code to work with.
  17. Offline


    Mr360zack Craftbukkit 1.6.4 R2.0

    xTrollxDudex Sorry for pastebin expire I'll post it on first of this topic soon

    Bump, Thanks:'(

    Do I need to create Maven in my plugin?
    Maven is importain to make my plugin works?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
  18. Offline



    Maven projects make it easier to work with other developers. Consider this: Some people use Eclipse, some use Netbeans, some use ItelliJ.

    Let's say your IDE is Eclipse... And you download one of my Netbeans projects... You'll have to convert from Netbeans to Eclipse before you can even open the project in your IDE.

    Also, when it comes to building, you might be missing a lot of dependencies... Having to try and 1st figure out all the dependencies and 2nd downloading the JARs can be a hassle.

    This is where Maven shines: standardization and dependency management.

    Essentially, it makes it easier to work with other developers.

    If you want to recruit other developers to do a massive project, then convert to Maven.

    If you want to solo your project, don't worry about it.
    tackleza likes this.
  19. Offline


    Europia79 Thank you very mush for good knowledge and easy expand about Maven:)
  20. Offline



    The line numbers are not correct in the pastebin because you didn't paste all the code (the imports).

    Before worrying about Maven, you should definitely download either Mercurial or Git and use one of those to publish your code to either or

    Then you won't have to re-paste your code to pastebin everytime you want to ask a question on the forums.

    You can just link to your repository.

    Here's a github example:

    Here's a bitbucket example:

    As far as your specific problem, it's interesting, but I don't know if we have enough information to help you. Which is why I suggest you publish to a repository.

    Some information that might help us help you:

    Go into your Linux terminal and run this command:
    java -version
    What is the output ? Also, link the startup script for your server. I want to make 100% that you're running jre7

    Also, i'm curious to see (specifically line 56) since this is causing the error.

    Hopefully we can get this fixed. Good luck!
    tackleza likes this.
  21. Offline


    Europia79 Sure

    Here my server output

    java version "1.8.0"
    Java(TM) SE Runtime Environment (build 1.8.0-b132)
    Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
    I think it's not on server problem becuase this problem happen on my PC too!
    It's Errror line 36 on playerbin

    Here my Full class of

    I'll learn how to use git soon, Thank you for everything :)
  22. Offline


    You are sure you are compiling and running your server on the exact same versions, correct?
  23. Offline


    Mr360zack version that you mean is bukkit or java?

    if you mean bukkit
    -Yess, 100% save version

    if you mean java
    - I'm not sure about java. But I newest version everything

    Here's my java

    I have tested it on my PC, Same as server (Random class not found)
    I compile and test it on same PC, So java should same right?

    I just install java JDK and it's will auto install java runtime for me

    Thanks, Tackle
  24. Offline



    actually, i think running with a different Java version would produce a different error than ClassNotFoundException.

    The jdk and the jre don't have to be the same: The jre has be to greater than or equal to the jdk. The jre version cannot be less than the jdk version. And also, you can have more than one jre installed and from your server startup script, you can choose which version you want to use. Which is why I asked to see the startup script.

    But I really don't think this is the problem because if it was... you would get an UnsupportedClassVersionError or an ExceptionInInitializerError (both on startup).
    tackleza and Mr360zack like this.
  25. Offline



    Here is my PC startup Script(I show my Startup for my PC too because Classnotfound on my pc too when run for a while)

    Very simple
    SET BINDIR=%~dp0
    CD /D "%BINDIR%"
    "C:\Program Files (x86)\Java\jre7\bin\java.exe" -Xmx1G -Xms1G -jar bukkit.jar
    There are no Java folder in "C:\Program Files" because I install java 32bit only



    Here my server startup script

    1. #!/bin/sh
    2. java -Xmx13000M -Xms13000M -server -XX:+UseG1GC -XX:+OptimizeStringConcat -XX:+UseFastAccessorMethods -Xrs -XX:+UseCompressedOops -XX:+AggressiveOpts -XX:ThreadPriorityPolicy=42 -XX:CompileThreshold=1500 -XX:+TieredCompilation -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -XX:+UnlockExperimentalVMOptions -XX:+UseAdaptiveGCBoundary -XX:parallelGCThreads=9 -XX:+UseGCOverheadLimit -XX:+UseBiasedLocking -XX:MaxGCPauseMillis=50 -Xverify:none -jar bukkit.jar nogui

    Thank you:)
  26. Offline


    Bump :)

    Anything wrong with my Eclipse and plugin.yml?
    As I said, first time is working fine and for a while Class not found
  27. Offline


    at org.spigotmc.netty.NettyNetworkManager.b(

    Try using official build...
  28. Offline



    Thanks for your suggest, But I tried that before and class still not found

    So I don't know why orther plugins don't have problem like my plugin:'(
  29. Offline


    From image


    Countdowncmd$1 is anonymous class

    Countdowncmd$1 is in my plugin (.jar) file but why it's said classnotfound
    Countdowncmd$1 <-- this path will executing when I use countdown command with extra option that is restart server (I'll used it when I need to restart server and announer to player Restart server message with countdown and it's will stop server by itself)


    From this images in Red area that is anonymous class and it's will get unload when not used
    I don't know what the happen but sometime class still loaded sometime not load (80% it's will unload)

    There has anyway to protect my class unload and if my class unload why it's can't load it back like orther plugin?:'(

    This is other error Classnotfound it's same as Countdown as first topic said

    Server uptime : 2hour 9min

    As I said, It's random unload my class

    15:59:58 [SEVERE] Exception in thread "Timer-103"
    15:59:58 [SEVERE] java.lang.NoClassDefFoundError: com/smilekrub/TackleSmilekrub/serverevent/quicksand/QuickSandTask$2
    15:59:58 [SEVERE]      at
    15:59:58 [SEVERE]      at java.util.TimerThread.mainLoop(Unknown Source)
    15:59:58 [SEVERE]      at Source)
    15:59:58 [SEVERE] Caused by: java.lang.ClassNotFoundException: com.smilekrub.TackleSmilekrub.serverevent.quicksand.QuickSandTask$2
    15:59:58 [SEVERE]      at$ Source)
    15:59:58 [SEVERE]      at$ Source)
    15:59:58 [SEVERE]      at Method)
    15:59:58 [SEVERE]      at Source)
    15:59:58 [SEVERE]      at
    15:59:58 [SEVERE]      at
    15:59:58 [SEVERE]      at java.lang.ClassLoader.loadClass(Unknown Source)
    15:59:58 [SEVERE]      at java.lang.ClassLoader.loadClass(Unknown Source)
    15:59:58 [SEVERE]      ... 3 more
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
  30. Offline


    bump :'(

    Caused by: java.lang.ClassNotFoundException: com.smilekrub.TackleSmilekrub.commands.admin.Countdowncmd$1

    See?. Class still here, But it's said class not found

Thread Status:
Not open for further replies.

Share This Page