Fatal errors on dedicated servers

Issue #94 resolved
mezzodrinker created an issue

When trying to run a dedicated (as in: not “Open to LAN”) server with MobTalker2 installed, the below error messages are displayed in the logs and clients who try to interact with a mob are kicked from the server with an error:

[Server thread/FATAL] [MobTalker2.NetworkManager/mobtalker2]: Failed to register message type 'MessageShowText'java.lang.ClassNotFoundException: net.mobtalker.mobtalker2.common.network.MessageShowText$Handler
[Server thread/FATAL] [MobTalker2.NetworkManager/mobtalker2]: Failed to register message type 'MessageShowMenu'java.lang.ClassNotFoundException: net.mobtalker.mobtalker2.common.network.MessageShowMenu$Handler
[Server thread/FATAL] [MobTalker2.NetworkManager/mobtalker2]: Failed to register message type 'MessageShowSprite'java.lang.ClassNotFoundException: net.mobtalker.mobtalker2.common.network.MessageShowSprite$Handler
[Server thread/FATAL] [MobTalker2.NetworkManager/mobtalker2]: Failed to register message type 'MessageShowScene'java.lang.ClassNotFoundException: net.mobtalker.mobtalker2.common.network.MessageShowScene$Handler
[Server thread/FATAL] [MobTalker2.NetworkManager/mobtalker2]: Failed to register message type 'MessageHideTexture'java.lang.ClassNotFoundException: net.mobtalker.mobtalker2.common.network.MessageHideTexture$Handler
[Server thread/FATAL] [MobTalker2.NetworkManager/mobtalker2]: Failed to register message type 'MessageGuiConfig'java.lang.ClassNotFoundException: net.mobtalker.mobtalker2.common.network.MessageGuiConfig$Handler

Please find a full server log attached.

It appears that errors are caused by the inner class Handler of the RPC classes MessageShowText, MessageShowMenu, MessageShowSprite, MessageShowScene, MessageHideTexture and MessageGuiConfig being marked as @SideOnly( CLIENT ). This means that the classes will not be loaded on servers, which in turn results in a ClassNotFoundException when trying to load them in NetworkManager#load().

I assume that one of the following scenarios is true:

  • Chimaine never meant for MobTalker2 to be run on a dedicated server, so MobTalker2 on a server has never worked before.
  • The error was introduced due to major changes in Minecraft/Forge in the jump from 1.7.10 to 1.8 and was unaccounted for because MobTaker2 on a server was never tested.

Either way, it would make sense to determine whether making MobTalker2 server-compatible is possible at all and, in case it is not, give reasonable error messages to the user so they can react accordingly.

Comments (4)

  1. mezzodrinker reporter

    Issue appears to be caused by @SideOnly annotations on the message handler classes. According to the SimpleNetworkWrapper documentation, this is not necessary, as messages are only ever sent client → server or server → client, so there’s no possibility that the server would act as client. Still, being able to load the handler classes is necessary in order to correctly register the message IDs.

    Not sure if this was just overthought or done on purpose; Either way, it’s an easy fix. First tests gave good results.

  2. Log in to comment