Class Cast Exception?!

Discussion in 'Plugin Development' started by ShootToMaim, Apr 14, 2012.

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

    ShootToMaim

    What. The. F***. After all my hard work, this pops up:
    Code:
    2012-04-14 16:28:30 [SEVERE] Could not load 'plugins\JailLikeHell v4.1.5.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassCastException: class code.husky.JLH
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:150)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:422)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.ClassCastException: class code.husky.JLH
        at java.lang.Class.asSubclass(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:140)
        ... 8 more
    
    Any help is appreciated. The faster you post the answer, the better. Thank you!
    Moved from Bukkit Help.
     
  2. Offline

    dillyg10

    Source!
     
  3. Offline

    DrAgonmoray

  4. Offline

    ShootToMaim

  5. Offline

    CorrieKay

    source!

    Show Spoiler
    post your source code silly!
     
  6. Offline

    ShootToMaim

    Gr. I hope no one steals my code...
     
  7. Offline

    Njol

    Maybe your main class doesn't extend JavaPlugin?
     
  8. Offline

    ShootToMaim

    It does.
     
  9. Offline

    Musaddict

    I dont think you have your plugin.yml synced to your actual main class. Make sure:
    A) In plugin.yml, your "main" field is whatever you actual main field is.
    -or-
    B) Set your main class in the package "code.husky" and name the class "JLH"
     
  10. Offline

    ShootToMaim

  11. Offline

    Musaddict

    :confused: Thats the largest main class I've ever seen. You should really create new typed classes and organize each item based on its class (i.e. put commands in your Commands class). That would help a lot. Your main class should always only contain what it does when enabled (i.e. load files from a separate class, or say "Hey, im enabled" or something, not every method in your plugin). It's better to extend JavaPlugin and implement Listener, then register the other classes in your main.
     
  12. Offline

    ShootToMaim

    -_Husky_-
    Read this thread, and find the solution please :D.
    Thanks.
     
  13. Offline

    Technius

    That is the weirdest CCE I've seen...
     
  14. Offline

    Musaddict

    I'm tellin ya, a lil' organization will go a LONG way. Since it looks like your plugin is all in your main class, that doesnt help debugging... It points to something being wrong with the class, but that could be anything! If you make new classes, and it STILL points to your main class, then we can take a more thorough look.
     
  15. Offline

    ferrybig

    is the class file correct implemented inside the jar file?
     
  16. Offline

    AmberK

    Did you compile against JRE 1.7.0?
     
  17. Offline

    ferrybig

    using an jre1.7.0 class on an jre1.6.0 would give an other exception "unsupportted major.minor version"
     
  18. Offline

    PandazNWafflez


    Well that just accidentally solved my problem after ages of searching. Lol
     
  19. Offline

    ShootToMaim

    I've deleted jre 1.6.0. All I have now is jre 1.7.0, and yet this still isn't working.
    I was receiving the unsupported major.minor version error, but I fixed it by deleting jre 1.6.0.

    Yes.

    Yup.

    Daniel Heppner told me to give you this:
    https://github.com/Bukkit/Bukkit/bl.../org/bukkit/plugin/java/JavaPluginLoader.java
    It's the JavaPluginLoader, which is related to the error.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  20. Offline

    Musaddict

    First thing; "Unkown source".
    Second thing; here's line 140 of the JavaPluginLoader:
    Code:java
    1.  
    2. Class<? extends JavaPlugin> plugin = jarClass.asSubclass(JavaPlugin.class);
    3.  


    That line correlates the first error line that I quoted "at java.lang.Class.asSubclass"

    Things to double check:
    1. does your main jar extend Java Plugin
    2. do you have the bukkit API hooked into the compiler
    That's the only thing I can think of.

    You could also try remaking the first part of the plugin, then copy over the rest of your code. I would take that as an opportunity to organize your code into classes! Especially with as much code that you have, it'd do loads for organization and debugging.
     
  21. Offline

    Daniel Heppner

    I suggested the first, second is a good idea too. I can't imagine why this would suddenly start happening though.
     
  22. Offline

    ShootToMaim

    "do you have the bukkit API hooked into the compiler"
    Uh oh.

    Okay, I added the Bukkit API (sorry, new to Bukkit) after my computer got wiped a few days ago.
    Now i'm getting this error:
    Code:
    2012-04-17 17:27:26 [SEVERE] Could not load 'plugins\JailLikeHell v4.1.5.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.Error: Unresolved compilation problems:
        The import com.platymuus cannot be resolved
        The import com.platymuus cannot be resolved
        The import ru cannot be resolved
        The import ru cannot be resolved
        The import ru cannot be resolved
        The import ru cannot be resolved
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        The method setGroup(String, String) in the type JLH is not applicable for the arguments (String, List<capture#2-of ?>)
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionsEx cannot be resolved
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        Group cannot be resolved to a type
        Type mismatch: cannot convert from element type Object to Group
        PermissionManager cannot be resolved to a type
        PermissionGroup cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionGroup cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionManager cannot be resolved to a type
     
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:148)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:422)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.Error: Unresolved compilation problems:
        The import com.platymuus cannot be resolved
        The import com.platymuus cannot be resolved
        The import ru cannot be resolved
        The import ru cannot be resolved
        The import ru cannot be resolved
        The import ru cannot be resolved
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        The method setGroup(String, String) in the type JLH is not applicable for the arguments (String, List<capture#2-of ?>)
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionsEx cannot be resolved
        PermissionsPlugin cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        Group cannot be resolved to a type
        Type mismatch: cannot convert from element type Object to Group
        PermissionManager cannot be resolved to a type
        PermissionGroup cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionGroup cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionsPlugin cannot be resolved to a type
        PermissionManager cannot be resolved to a type
        PermissionManager cannot be resolved to a type
     
        at code.husky.JLH.<init>(JLH.java:3)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:144)
        ... 8 more
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  23. Offline

    -_Husky_-

    Simple fix.
     
    ShootToMaim likes this.
  24. Offline

    ShootToMaim

    Fixed it. I just fixed all the errors
    Thanks to h31ix for helping.

    Go on Skype or Steam more often D:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
Thread Status:
Not open for further replies.

Share This Page