Jump to content

weird java.lang.InstantiationException when registering EventHandler


blooditor

Recommended Posts

Hey,

 

I got a weird java.lang.InstantiationException whenever I register my EventHandler class in the preInit method. The events still get called so everything works fine - there is just the error message in the console every time:

 

Spoiler

(3x:)

 java.lang.InstantiationException
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at java.lang.reflect.Constructor.newInstance(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:103)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:85)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.mcb.server.MainClass.preInit(MainClass.java:93)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at java.lang.reflect.Method.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at java.lang.reflect.Method.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventBus.post(EventBus.java:275)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at java.lang.reflect.Method.invoke(Unknown Source)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at com.google.common.eventbus.EventBus.post(EventBus.java:275)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:355)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:120)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:500)
[01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]:     at java.lang.Thread.run(Unknown Source)

Spoiler

 public MCBEventHandler eventManager = new MCBEventHandler();

 

@EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        MinecraftForge.EVENT_BUS.register(eventManager);
        FMLCommonHandler.instance().bus().register(eventManager);
        MinecraftForge.ORE_GEN_BUS.register(eventManager);
        System.out.println("Event Handler Initialized");
        
    }

Also important: I do have an empty constructor for the event handler class.

So since everything works that problem is not that bad - it's just annoying having the same error messages every time.

 

Thanks for the help.

Edited by blooditor
Link to comment
Share on other sites

57 minutes ago, diesieben07 said:

Post MCBEventHandler.

Spoiler

public class MCBEventHandler {

    public MCBEventHandler() {
    }
    
     @SubscribeEvent
        public void loadChunk(ChunkEvent.Load e){
       
        }

         @SubscribeEvent
        public void playerLogin(PlayerEvent.PlayerLoggedInEvent e){
    

        }

        @SubscribeEvent
        public void playerLogout(PlayerEvent.PlayerLoggedOutEvent e){
          

        }
         @SubscribeEvent
        public void onHit(LivingAttackEvent e){
           
        }
        @SubscribeEvent
        public void onHurt(LivingHurtEvent e){
           
        }
        
         @SubscribeEvent
        public void onKill(LivingDeathEvent e){
         
        }
        @SubscribeEvent
        public void spawn(EntityJoinWorldEvent e){
           
        }
        @SubscribeEvent
        public void onMove(LivingUpdateEvent e){
            
        }
        @SubscribeEvent
        public void interact(EntityInteractEvent e){

        }
        @SubscribeEvent
        public void chat(ServerChatEvent e){
          
        }
       @SubscribeEvent
        public void playerLoggedIn(FMLNetworkEvent.ServerConnectionFromClientEvent event)
        {
           
            NetHandlerPlayServer handler = (NetHandlerPlayServer) event.handler;
            EntityPlayerMP player = handler.playerEntity;

          
        }
       @SubscribeEvent
        public void attackEntity(AttackEntityEvent e){
          
        }
        

        @SubscribeEvent
        public void tick(ServerTickEvent e){
          
        }
        
        @EventHandler
        public void serverStop(FMLServerStoppingEvent e){
         
        }
        
   
        @SubscribeEvent
        public void blockInteract(final PlayerInteractEvent e){
         
        }
        @SubscribeEvent
        public void playerUseItem(PlayerUseItemEvent e){
            
        }
        
        @SubscribeEvent
        public void explosion(ExplosionEvent e){
           
        }
        
        @SubscribeEvent
        public void detonate(ExplosionEvent.Detonate e){
          
        }
                
        
        
        @SubscribeEvent
        public void blockBreak(BlockEvent.BreakEvent e){
          
        }        
        @SubscribeEvent
        public void blockPlace(BlockEvent.PlaceEvent e){
          
        }
        
        @SubscribeEvent
        public void blockPlace(BlockEvent.MultiPlaceEvent e){
          
        }
        @SubscribeEvent
        public void entitySpawn(EntityJoinWorldEvent e){
          
        }
        @SubscribeEvent
        public void oreGen(PlayerChangedDimensionEvent e){
           
        }
        @SubscribeEvent
        public void ch(PopulateChunkEvent.Pre e){
           
        }
        @SubscribeEvent
        public void vehiclePlaced(EntityJoinWorldEvent event)
        {
           
        }
        @SubscribeEvent
        public void enderTp(EnderTeleportEvent e){
            
        }

        @SubscribeEvent
        public void worldTick(WorldTickEvent e){
         
        }
        @SubscribeEvent
        public void command(CommandEvent e){
           
        }

Sorry I had to remove the method content for security reasons.

Link to comment
Share on other sites

32 minutes ago, diesieben07 said:

What Minecraft version are you using? EntityInteractEvent has not existed for a while, please update.#

Using MC 1.8.

EntityInteractEventworks fine.

33 minutes ago, diesieben07 said:

 

And this is complete bullshit.

Nope it isn't. I'm not creating my own server mod for others copying stuff from it.

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.