Jump to content

[SOLVED] java.lang.noClassDefFound error


Toma™

Recommended Posts

So recently I updated my mod and when I tried to start it, I got this crash:

Spoiler

---- Minecraft Crash Report ----
// I just don't know what went wrong :(

Time: 10/5/18 4:49 PM
Description: Initializing game

java.lang.NoClassDefFoundError: com/toma/pubgmc/blocks/airdrop/Airdrop
    at com.toma.pubgmc.util.handlers.RegistryHandler.onBlockRegister(RegistryHandler.java:50)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_RegistryHandler_onBlockRegister_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:775)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:466)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:377)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.ClassNotFoundException: com.toma.pubgmc.blocks.airdrop.Airdrop
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more
Caused by: java.lang.NullPointerException
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182)
    ... 19 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at com.toma.pubgmc.util.handlers.RegistryHandler.onBlockRegister(RegistryHandler.java:50)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_RegistryHandler_onBlockRegister_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:775)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:466)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:377)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_51, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 405809000 bytes (387 MB) / 883949568 bytes (843 MB) up to 2863661056 bytes (2731 MB)
    JVM Flags: 4 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx3072m -Xms256m -XX:PermSize=256m
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID        | Version      | Source                        | Signature                                |
    |:----- |:--------- |:------------ |:----------------------------- |:---------------------------------------- |
    | UCH   | minecraft | 1.12.2       | minecraft.jar                 | None                                     |
    | UCH   | mcp       | 9.42         | minecraft.jar                 | None                                     |
    | UCH   | FML       | 8.0.99.99    | forge-1.12.2-14.23.5.2768.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCH   | forge     | 14.23.5.2768 | forge-1.12.2-14.23.5.2768.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCH   | pubgmc    | 2.2.0-alpha  | PUBGMC 2.2.0-alpha.jar        | None                                     |

    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 399.07' Renderer: 'GeForce GTX 1050 Ti/PCIe/SSE2'
    Launched Version: forge-14.23.5.2768
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 1050 Ti/PCIe/SSE2 GL version 4.6.0 NVIDIA 399.07, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 4x Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz

 

Before it was working perfectly (and I didn't even change anything inside the classes it's pointing to)

 

Since it's pointing to my RegistryHandler class, there's the class:

Spoiler

package com.toma.pubgmc.util.handlers;

import com.toma.pubgmc.Main;
import com.toma.pubgmc.blocks.airdrop.TileEntityAirdrop;
import com.toma.pubgmc.blocks.lamp.TileEntityLamp;
import com.toma.pubgmc.blocks.lootspawn.TileEntityLootSpawner;
import com.toma.pubgmc.commands.GenerateLootcmd;
import com.toma.pubgmc.commands.Leavecmd;
import com.toma.pubgmc.entity.EntityGrenade;
import com.toma.pubgmc.events.ClientTickEvents;
import com.toma.pubgmc.events.EntityHitEvents;
import com.toma.pubgmc.events.GunEvents;
import com.toma.pubgmc.events.ModEventHandler;
import com.toma.pubgmc.init.ModBlocks;
import com.toma.pubgmc.init.ModItems;
import com.toma.pubgmc.misc.KeyBinds;
import com.toma.pubgmc.render.RenderGrenade;
import com.toma.pubgmc.util.IHasModel;
import com.toma.pubgmc.util.Reference;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

@EventBusSubscriber
public class RegistryHandler
{
    
    @SubscribeEvent
    public static void onItemRegister(RegistryEvent.Register<Item> event)
    {
        event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
    }
    
    @SubscribeEvent
    public static void onBlockRegister(RegistryEvent.Register<Block> event)
    {
        event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
    }
    
    @SubscribeEvent
    public static void onModelRegister(ModelRegistryEvent event)
    {
        for(Item item : ModItems.ITEMS)
        {
            if(item instanceof IHasModel)
            {
                ((IHasModel)item).registerModels();
            }
        }
        
        for(Block block : ModBlocks.BLOCKS)
        {
            if(block instanceof IHasModel)
            {
                ((IHasModel)block).registerModels();
            }
        }
        
    }
    
    public static void initRegistries()
    {
        NetworkRegistry.INSTANCE.registerGuiHandler(Main.instance, new GuiHandler());
    }
    
    public static void serverRegistries(FMLServerStartingEvent event)
    {
        event.registerServerCommand(new Leavecmd());
        event.registerServerCommand(new GenerateLootcmd());
    }
    
    public static void registerEvents()
    {
        MinecraftForge.EVENT_BUS.register(new ModEventHandler());
        MinecraftForge.EVENT_BUS.register(new EntityHitEvents());
        MinecraftForge.EVENT_BUS.register(new ClientTickEvents());
        MinecraftForge.EVENT_BUS.register(new GunEvents());
    }
    
    public static void preInitConfig(FMLPreInitializationEvent ev)
    {
        ConfigHandler.registerConfig(ev);
    }
    
    public static void registerKeyBinding()
    {
        ClientRegistry.registerKeyBinding(KeyBinds.RELOAD);
        ClientRegistry.registerKeyBinding(KeyBinds.FIREMODE);
    }
    
    public static void registerTileEntities()
    {
        GameRegistry.registerTileEntity(TileEntityAirdrop.class, Reference.MOD_ID + ":airdrop");
        GameRegistry.registerTileEntity(TileEntityLamp.class, Reference.MOD_ID + ":lamp");
        GameRegistry.registerTileEntity(TileEntityLootSpawner.class, Reference.MOD_ID + ":lootspawner");
    }
    
    public static void registerEntityRenderers()
    {
        RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new IRenderFactory<EntityGrenade>()
        {

            @Override
            public Render<? super EntityGrenade> createRenderFor(RenderManager manager)
            {
                return new RenderGrenade<>(manager);
            }
            
        });
    }
}
 

 

I checked the .jar file if there are all classes which should and nothing seems to be missing. I tried to do some research but didn't find solution. Also maybe is it cause because I'm using old forge? (1.12.2 mc, 14.23.4.2705 forge)

Edited by Toma™
solved
Link to comment
Share on other sites

Your issue is likely caused by something else somewhere else but since you are using static initializers everything gets messed up and you see this error report. One more reason to stop using static initializers.

Also don't use IHasModel. It is stupid. Every item needs a model. Every single one. And nothing required for model registering is private.

Also these

17 minutes ago, Toma™ said:

        MinecraftForge.EVENT_BUS.register(new ClientTickEvents());

 

17 minutes ago, Toma™ said:

 public static void registerKeyBinding()
    {
        ClientRegistry.registerKeyBinding(KeyBinds.RELOAD);
        ClientRegistry.registerKeyBinding(KeyBinds.FIREMODE);
    }
    

Should be in your client proxy, not a common class.

 

17 minutes ago, Toma™ said:

GameRegistry.registerTileEntity(TileEntityAirdrop.class, Reference.MOD_ID + ":airdrop");
        GameRegistry.registerTileEntity(TileEntityLamp.class, Reference.MOD_ID + ":lamp");
        GameRegistry.registerTileEntity(TileEntityLootSpawner.class, Reference.MOD_ID + ":lootspawner");

Stop using a deprecated method. Use the overload which takes a ResourceLocation.

 

As for the actual issue - it's impossible to tell from the information you've provided. Please provide a link to your github repository so I can test it locally and trace the actual issue.

Or simply stop using static initializers. In this case the acual issue will be the one you catch.

Link to comment
Share on other sites

Actually, one is package (the lowercase one) where are classes (the block class - upper case one and when I started modding, I wasn't doing block classes like BlockXxxx, but I simply used to put the name of it there).

Looking into it now, I see only package and class name, but maybe eclipse is getting confused by that - it's changed now

Link to comment
Share on other sites

12 minutes ago, Toma™ said:

Actually, one is package (the lowercase one) where are classes (the block class - upper case one and when I started modding, I wasn't doing block classes like BlockXxxx, but I simply used to put the name of it there).

2packages.PNG.6a23c0b2c4567ab564213be9e32ee588.PNG

 

And in the .jar file the upper-case turns into lower-case which leads to duplicate files which leads to the inability to load the duplicated class. In my local environment as soon as I dealt with the duplicated package/classes(and a few other compilation issues) I was able to boot the game just fine.

Link to comment
Share on other sites

oh I see. That's caused because last time I was uploading whole main folder to GitHub I had the package named with uppercase A, but in latest update I changed it to all lower case characters and since I was uploading new files and not replacing the old ones, it kept both folders. But in my eclipse I have only 1 package named airdrop. 

I'm able to load it in IDE too, but as soon as I export the mod (using the gradlew build obviously) I get the crash report I posted above. Maybe there are some references to the old package name which didn't get replaced or I don't know

Link to comment
Share on other sites

I am able to launch your mod in a normal(non-dev) environment. There were a few compile errors I had to correct though and one of your classes was referencing the upper-case package.

31 minutes ago, Toma™ said:

oh I see. That's caused because last time I was uploading whole main folder to GitHub I had the package named with uppercase A, but in latest update I changed it to all lower case characters and since I was uploading new files and not replacing the old ones, it kept both folders.

Use github integration instead of uploading files manually. Or at least the command line git client.

Link to comment
Share on other sites

36 minutes ago, V0idWa1k3r said:

I am able to launch your mod in a normal(non-dev) environment. There were a few compile errors I had to correct though and one of your classes was referencing the upper-case package.

Use github integration instead of uploading files manually. Or at least the command line git client.

 

Alright, I'll try to change some stuff you suggested me above and build the mod and try it. Thanks for your time and help

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
  • Topics

×
×
  • Create New...

Important Information

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