Jump to content

There's no "side only", but my server throws a NoClassDefFoundError


jeffryfisher

Recommended Posts

I need help before I pull out all of my hair...

 

I have a mod that runs perfectly in Eclipse SP. However, when I build the mod and install it on my server, the server fails to start. I don't see "side only" anywhere, so I am flummoxed. I've broken apart the offending code as much as I can:

    System.out.println (MODID + " attempting to declare my callback handle.");
    classAltPaintingSpawnCallback cb;    // Succeeds
    
    System.out.println (MODID + " attempting to construct my callback instance.");
    cb = new classAltPaintingSpawnCallback ();    // Line 125 blows up

The server crashes with NoClassDefFoundError on line 125. It doesn't even begin to run the CallBack's constructor. Here's the entire java file for the classAltPaintingSpawnCallback class:

package jrfpaintings;

import io.netty.buffer.ByteBuf;

import java.lang.reflect.Field;

import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.Entity;

import com.google.common.base.Function;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.internal.FMLMessage.EntitySpawnMessage;

public class classAltPaintingSpawnCallback implements Function<EntitySpawnMessage, Entity> {

  protected Field fieldStream;

  public classAltPaintingSpawnCallback() {      // This will be constructed in the init phase
    System.out.println ("Constructing classAltPaintingSpawnCallback");
    try {   // Crack open the message and enable access to dataStream via Field variable (reflection)
      this.fieldStream = EntitySpawnMessage.class.getDeclaredField ("dataStream");
      this.fieldStream.setAccessible (true);
    } catch (NoSuchFieldException e) {
      System.out.println ("ERROR: In classAltPaintingSpawnCallback constructor, " + e.getMessage ());
    }
  }

  /**
   * Helper class with one function to parse message and call the correct entity constructor that returns an instance of my entity
   * class. Got all that? I wrote it, and it still makes my head hurt.
   *
   * Why does the message protocol delay reading my extra data until after entity construction? I may never know, but I do know that
   * it's there waiting for me, so I'm taking it by force. 
   */
  @Override
  public Entity apply(EntitySpawnMessage m) {
    WorldClient wc = FMLClientHandler.instance ().getWorldClient ();
    try {
      ByteBuf b = (ByteBuf) fieldStream.get (m);    // Steal the dataStream from message m
      int x = b.readInt ();                         // world tile x (+ is East)
      int y = b.readInt ();                         // world tile y (+ is Up)
      int z = b.readInt ();                         // world tile z (+ is South)
      int SWNE = b.readByte ();                     // Compass dir 0-3 is S, W, N, E
      int lot = b.readByte ();                      // Texture number 0-15 taken from carpet color used to craft item
      String title = ByteBufUtils.readUTF8String (b);
      return new classAltPainting (wc, x, y, z, SWNE, lot, title);
    } catch (ReflectiveOperationException e) {
      System.out.println ("ERROR:  In classAltPaintingSpawnCallback.apply(), " + e.getMessage ());
      return null;
    }
  }
}

It works flawlessly in Eclipse, but on the server it doesn't even emit the first println in the constructor.

 

The error log:

jrfpaintings attempting to construct my callback instance.
Init jrfwalls
[16:42:10] [server thread/ERROR] [FML]: Fatal errors were detected during the transition from INITIALIZATION to POSTINITIALIZATION. Loading cannot continue
[16:42:10] [server thread/ERROR] [FML]:
        mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized
        FML{7.10.18.1180} [Forge Mod Loader] (forge-1.7.10-10.13.0.1180-universal.jar) Unloaded->Constructed->Pre-initialized->Initialized
        Forge{10.13.0.1180} [Minecraft Forge] (forge-1.7.10-10.13.0.1180-universal.jar) Unloaded->Constructed->Pre-initialized->Initialized
        jrfmoonsensor{v1.7.2-0.01.04 Beta} [uncle Jeff's Moon Sensor] (jrfmoonsensor-1.7.2-00.01.04.jar) Unloaded->Constructed->Pre-initialized->Initialized
        jrfnethergem{v0.01.04 Beta} [uncle Jeff's Nethergem Mod] (jrfnethergem-1.7.10-00.01.05.jar) Unloaded->Constructed->Pre-initialized->Initialized
        jrfpaintings{v1.7.10-0.00.01 Alpha} [uncle Jeff's Paintings Mod] (jrfpaintings-1.7.10-00.00.01.jar) Unloaded->Constructed->Pre-initialized->Errored
        jrfwalls{v1.7.2-0.01.04 Beta} [uncle Jeff's Walls Mod] (jrfwalls-1.7.2-00.01.04.jar) Unloaded->Constructed->Pre-initialized->Initialized
[16:42:10] [server thread/ERROR] [FML]: The following problems were captured during this phase
[16:42:10] [server thread/ERROR] [FML]: Caught exception from jrfpaintings
java.lang.NoClassDefFoundError: java/lang/ReflectiveOperationException
        at jrfpaintings.classAltPaintingsMod.init(classAltPaintingsMod.java:125) ~[classAltPaintingsMod.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[FMLModContainer.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.7.10.jar:?]
        at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]
        at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.7.10.jar:?]
        at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]
        at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691) [Loader.class:?]
        at cpw.mods.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:97) [FMLServerHandler.class:?]
        at cpw.mods.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:318) [FMLCommonHandler.class:?]
        at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:210) [lt.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:387) [MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?]
Caused by: java.lang.ClassNotFoundException: java.lang.ReflectiveOperationException
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.6.0_45]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.6.0_45]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.6.0_45]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:104) ~[launchwrapper-1.9.jar:?]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        ... 33 more
[16:42:11] [server thread/ERROR]: Encountered an unexpected exception
cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: java/lang/ReflectiveOperationException
        at cpw.mods.fml.common.LoadController.transition(LoadController.java:162) ~[LoadController.class:?]
        at cpw.mods.fml.common.Loader.initializeMods(Loader.java:692) ~[Loader.class:?]
        at cpw.mods.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:97) ~[FMLServerHandler.class:?]
        at cpw.mods.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:318) ~[FMLCommonHandler.class:?]
        at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:210) ~[lt.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:387) [MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?]
Caused by: java.lang.NoClassDefFoundError: java/lang/ReflectiveOperationException
        at jrfpaintings.classAltPaintingsMod.init(classAltPaintingsMod.java:125) ~[classAltPaintingsMod.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[FMLModContainer.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.7.10.jar:?]
        at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]
        at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.7.10.jar:?]
        at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) ~[LoadController.class:?]
        at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691) ~[Loader.class:?]
        ... 5 more
Caused by: java.lang.ClassNotFoundException: java.lang.ReflectiveOperationException
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.6.0_45]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.6.0_45]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.6.0_45]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:104) ~[launchwrapper-1.9.jar:?]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.6.0_45]
        at jrfpaintings.classAltPaintingsMod.init(classAltPaintingsMod.java:125) ~[classAltPaintingsMod.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[FMLModContainer.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.7.10.jar:?]
        at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]
        at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.6.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.6.0_45]
        at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.7.10.jar:?]
        at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.7.10.jar:?]
        at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) ~[LoadController.class:?]
        at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691) ~[Loader.class:?]
        ... 5 more
[16:42:11] [server thread/ERROR]: This crash report has been saved to: /var/lib/games/minecraft/./crash-reports/crash-2014-08-08_16.42.11-server.txt

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Aha, very informative. Since my case involves reflection, I guess I have run into extreme bounds checking (i.e. parts of the class not used on the server are still being tested). I can already see an import that has a SideOnly attribute. That's probably the culprit. I'll see if I can recode my class without the offending import. Instead, I'll try to use a fully-qualified reference deeper in the class, surrounding it with isRemote. If that doesn't work, then I'll try to push the work into my proxy, with only the ClientProxy having the real reference to the client-only class.

 

I'll post my solution when I find it.

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Success! Since classAltPaintingSpawnCallback is only needed for processing a message received on the client side, I made it @SideOnly. Then I moved all references to it into my client proxy.

 

However, I'm still... disappointed at Java's error message. When it complained that a class wasn't found, it would have been nice to tell me *which* class wasn't found (and tell me that it was starting to analyze that callback class). I lost a lot of time because all it gave me was a line number in another class that had a "new classAltPaintingSpawnCallback()" expression, and classAltPaintingSpawnCallback happened to import one SideOnly class among a dozen imports. I won't be surprised to see more modders baffled by similar bugs.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.