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

    tackleza

    Hi, everyone:)

    I have problem that is My plugin error like this: http://pastebin.com/r58RA7Az
    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: http://pastebin.com/MkX1Xa3H
    Countdown Task: http://pastebin.com/pZtediXn
    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
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
     
  2. Offline

    caseif

    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

    tackleza

    Thank you for reply:)


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

    caseif

    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

    tackleza

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

    caseif

    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

    tackleza

    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

    caseif

    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

    tackleza

    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

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

    caseif

    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

    tackleza


    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

    caseif

    You may have more luck on the IRC channel (#[email protected]), 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

    tackleza

    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!

    Edit
    It's still not found!
     
  14. Offline

    tackleza

    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.
    com/xxxxxx/xxxxxxxx/commands/admin/Countdowncmd$1

    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

    Mr360zack

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

    xTrollxDudex

    tackleza
    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

    tackleza

    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

    Europia79

    tackleza

    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

    tackleza

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

    Europia79

    tackleza

    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 Github.com or Bitbucket.org

    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:
    https://github.com/Europia79

    Here's a bitbucket example:
    https://bitbucket.org/BillyGalbreath

    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:
    Code:
    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 Countdowncmd.java (specifically line 56) since this is causing the error.

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

    tackleza

    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 Countdowncmd.java

    http://pastebin.com/35RNy7yW

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

    Mr360zack

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

    tackleza

    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
    [​IMG]


    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

    Europia79

    tackleza

    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

    tackleza

    Europia79

    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
    Code:
    @ECHO OFF
    SET BINDIR=%~dp0
    CD /D "%BINDIR%"
    "C:\Program Files (x86)\Java\jre7\bin\java.exe" -Xmx1G -Xms1G -jar bukkit.jar
     
    EXIT(0);
    There are no Java folder in "C:\Program Files" because I install java 32bit only

    [​IMG]

    [​IMG]


    Here my server startup script

    Code:java
    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

    tackleza

    Bump :)

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

    RawCode

    at org.spigotmc.netty.NettyNetworkManager.b(NettyNetworkManager.java:230)

    Try using official build...
     
  28. Offline

    tackleza

    RawCode

    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

    tackleza

    From image

    [​IMG]

    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)

    [​IMG]

    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

    Code:
    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 com.smilekrub.TackleSmilekrub.serverevent.quicksand.QuickSandTask.run(QuickSandTask.java:163)
    15:59:58 [SEVERE]      at java.util.TimerThread.mainLoop(Unknown Source)
    15:59:58 [SEVERE]      at java.util.TimerThread.run(Unknown Source)
    15:59:58 [SEVERE] Caused by: java.lang.ClassNotFoundException: com.smilekrub.TackleSmilekrub.serverevent.quicksand.QuickSandTask$2
    15:59:58 [SEVERE]      at java.net.URLClassLoader$1.run(Unknown Source)
    15:59:58 [SEVERE]      at java.net.URLClassLoader$1.run(Unknown Source)
    15:59:58 [SEVERE]      at java.security.AccessController.doPrivileged(Native Method)
    15:59:58 [SEVERE]      at java.net.URLClassLoader.findClass(Unknown Source)
    15:59:58 [SEVERE]      at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
    15:59:58 [SEVERE]      at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
    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

    tackleza

    bump :'(

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

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

    [​IMG]
     
Thread Status:
Not open for further replies.

Share This Page