NoClassDefFoundError on 1.20.6
Just upgraded server version and anvilgui and now I can't use it.
Version
This server is running Paper version 1.20.6-112-master@347bbe3 (2024-05-26T22:17:48Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.20.6-90-b149584 (MC: 1.20.6)
Error
[08:11:23 WARN]: java.lang.NoClassDefFoundError: Could not initialize class me.usainsrht.sccore.anvilgui.AnvilGUI
[08:11:23 WARN]: at SCCore-1.3.2.jar//me.usainsrht.sccore.anvilgui.AnvilGUI$Builder.<init>(AnvilGUI.java:400)
[08:11:23 WARN]: at SCClaims-1.0.7.jar//me.usainsrht.scclaims.commands.ClaimCommand.execute(ClaimCommand.java:70)
[08:11:23 WARN]: at io.papermc.paper.command.brigadier.bukkit.BukkitCommandNode$BukkitBrigCommand.run(BukkitCommandNode.java:86)
[08:11:23 WARN]: at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73)
[08:11:23 WARN]: at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:31)
[08:11:23 WARN]: at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:19)
[08:11:23 WARN]: at net.minecraft.commands.execution.UnboundEntryAction.lambda$bind$0(UnboundEntryAction.java:8)
[08:11:23 WARN]: at net.minecraft.commands.execution.CommandQueueEntry.execute(CommandQueueEntry.java:5)
[08:11:23 WARN]: at net.minecraft.commands.execution.ExecutionContext.runCommandQueue(ExecutionContext.java:103)
[08:11:23 WARN]: at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:442)
[08:11:23 WARN]: at net.minecraft.commands.Commands.performCommand(Commands.java:349)
[08:11:23 WARN]: at net.minecraft.commands.Commands.performCommand(Commands.java:336)
[08:11:23 WARN]: at net.minecraft.commands.Commands.performCommand(Commands.java:331)
[08:11:23 WARN]: at net.minecraft.server.network.ServerGamePacketListenerImpl.performUnsignedChatCommand(ServerGamePacketListenerImpl.java:2202)
[08:11:23 WARN]: at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$14(ServerGamePacketListenerImpl.java:2176)
[08:11:23 WARN]: at net.minecraft.server.TickTask.run(TickTask.java:18)
[08:11:23 WARN]: at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:151)
[08:11:23 WARN]: at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24)
[08:11:23 WARN]: at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1511)
[08:11:23 WARN]: at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:195)
[08:11:23 WARN]: at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:125)
[08:11:23 WARN]: at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1488)
[08:11:23 WARN]: at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1411)
[08:11:23 WARN]: at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:135)
[08:11:23 WARN]: at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1377)
[08:11:23 WARN]: at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1238)
[08:11:23 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323)
[08:11:23 WARN]: at java.base/java.lang.Thread.run(Thread.java:1583)
[08:11:23 WARN]: Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: net/minecraft/world/entity/player/EntityHuman [in thread "Server thread"]
[08:11:23 WARN]: at java.base/java.lang.Class.forName0(Native Method)
[08:11:23 WARN]: at java.base/java.lang.Class.forName(Class.java:534)
[08:11:23 WARN]: at java.base/java.lang.Class.forName(Class.java:513)
[08:11:23 WARN]: at io.papermc.reflectionrewriter.runtime.AbstractDefaultRulesReflectionProxy.forName(AbstractDefaultRulesReflectionProxy.java:68)
[08:11:23 WARN]: at io.papermc.paper.pluginremap.reflect.PaperReflectionHolder.forName(Unknown Source)
[08:11:23 WARN]: at SCCore-1.3.2.jar//me.usainsrht.sccore.anvilgui.version.VersionMatcher.match(VersionMatcher.java:43)
[08:11:23 WARN]: at SCCore-1.3.2.jar//me.usainsrht.sccore.anvilgui.AnvilGUI.<clinit>(AnvilGUI.java:42)
[08:11:23 WARN]: ... 28 more
Code
public boolean execute(@NotNull CommandSender commandSender, @NotNull String cmd, @NotNull String[] args) {
if (args.length > 0) {
if (commandSender instanceof Player player) {
if (args[0].equalsIgnoreCase("debug") && commandSender.hasPermission("scclaims.command.debug")) {
if (args[1].equalsIgnoreCase("anvilgui")) {
try {
new AnvilGUI.Builder().plugin(SCClaims.getInstance())
.title(args[2])
.itemLeft(new ItemStack(Material.GRASS_BLOCK))
.open(player);
} catch (Exception | Error e) {
e.printStackTrace();
}
}
}
}
}
}
AnvilGUI version: 1.9.4-SNAPSHOT
Heres the shade config
Please see #327, this has been discussed before. You need to ensure that Paper remaps your plugin. Unfortunately there is no way to "tell" Paper to only re-map certain classes (i.e. Anvil-GUI classes). Are you using Paperweight?
I am not using paperweight or any nms related things in those plugins.
Check your server log file that your plugin gets remapped by paper.
Deleted the .paper-remapped folder and started the server again, both of my plugins didn't get remapped (SCClaims & SCCore)
What are the contents of the MANIFEST.MF file in your plugin's .jar file?
Manifest-Version: 1.0
Created-By: Maven Jar Plugin 3.2.0
Build-Jdk-Spec: 21
Where is SSCore located? Is it a normal spigot plugin inside the plugins folder? There must be a reason why it doesn't get remapped by Paper.
yes both sccore and scclaims are in plugins folder, they have paper plugin.ymls also i just saw that mentioned in the other issue
Apparently you can't shade the class files of AnvilGUI into a Paper Plugin, it assumes the NMS code to be mojang-mapped, so it doesn't do any remapping, I just asked on their Discord.
You can use my gradle version of AnvilGUI tho that has mojang mappings in it: https://github.com/mastercake10/AnvilGUI/tree/no_relocation
uhh how exactly? system scope?
by building the jar and shading it into your plugin
edit: you can also use the .jar on my repo: https://repo.spaceio.xyz/#browse/browse:maven-public:net%2Fwesjd%2Fanvilgui%2F1.9.5-SNAPSHOT%2F1.9.5-20240510.204921-4%2Fanvilgui-1.9.5-20240510.204921-4.jar
I mean, how is this possible?
try this in your pom.xml:
<!-- AnvilGUI -->
<dependency>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui</artifactId>
<version>1.9.5-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Worked thanks. Are you guys going to publish a separate jar for mojang mappings?
The jar you're using right now (my no-relocation branch) has both mappings in it, so it works on both paper and spigot. I don't know if there is any advantage in distributing two jar files. With both mappings in it, one could target paper and spigot at the same time.
I didn't know that these paper plugins were a thing, so I think I will create a PR soon for my fork.
Lets leave this issue open until its officially resolved.
@UsainSrht As far as I've understood, you should be able to use the official AnvilGUI version in a Paper plugin as long as you set the paperweight-mappings-namespace to spigot in your MANIFEST.MF file. Have you tried that?
Taken from this information in the dev-announcements channel in the PaperMC Discord server:
Default Mappings Assumption
- By default, all Spigot/Bukkit plugins will be assumed to be Spigot-mapped if they do not specify their mappings namespace in the manifest. Conversely, all Paper plugins will be assumed to be Mojang-mapped if they do not specify their mappings namespace in the manifest.
- Spigot-mapped plugins will need to be deobfuscated on first load, Mojang-mapped plugins will not.
Manual Manifest Configuration
- For more complex setups, you can manually set the
paperweight-mappings-namespaceattribute in the manifest. Acceptable values aremojang,mojang+yarn(treated the same asmojang), orspigot.
The official AnvilGUI version is only compatible with Spigot-mapped plugins, which is why you will need to configure your manifest manually if you are creating a Paper plugin.
It's probably worth adding this information to the AnvilGUI README, if this solves your issue.
@UsainSrht did the above solve your issue? if so we should add to README
Helped in my case, thank you! Maybe also a helpful Link for anybody, who is running into the same issue: https://docs.papermc.io/paper/dev/project-setup#spigot-mappings
Yes, adding spigot paperweight mapping namespace solved the problem but wouldn't it cause other issues if someone uses both mojang mapping nms and anvilgui at the same time?
Yes, adding
spigotpaperweight mapping namespace solved the problem but wouldn't it cause other issues if someone uses both mojang mapping nms and anvilgui at the same time?
only if your plugin's MANIFEST.MF states that its using Mojang mappings. Otherwise the paper-remapper would automatically remap everything that is not mojang.
Running into this issue aswell, but I am unable to use spigot mappings Tried forking AnvilGUI, making its manifest use mojang mapping, but still running into this issue
Is there no real way to use this with a paper plugin and mojang mappings anymore?
fork: https://github.com/mineinabyss/AnvilGUI selfhosted repo: https://repo.mineinabyss.com/#/releases/net/wesjd/anvilgui/1.10.0-SNAPSHOT
Is there no real way to use this with a paper plugin and mojang mappings anymore?
No, there is no way to use spigot mappings for paper plugins. The server expects the paper plugin to use mojang mappings. So it needs an AnvilGUI API that has mojang mappings in it. I have a fork of AnvilGUI that has both mojang and spigot mappings in it, which (I think) should work with paper plugins, as mentioned here https://github.com/WesJD/AnvilGUI/issues/330#issuecomment-2133673489.
Running into this issue aswell, but I am unable to use spigot mappings
@Boy0000 Is there a reason why you are unable to use Spigot mappings?
Tried forking AnvilGUI, making its manifest use mojang mapping, but still running into this issue
That won't work, for several reasons. The primary reason being that AnvilGUI uses Spigot mappings, which means that the manifest must indicate this or else Paper will not remap the plugin correctly. Switching to Mojang mappings is not as simple as changing a manifest entry. The other reason is that the manifest of a library such as AnvilGUI won't necessarily be included in your plugin (depending on your Maven/Gradle config). In general (and in this case), it makes more sense to edit the manifest of your plugin instead. Because AnvilGUI only supports Spigot mappings, your plugin, and any other libraries you use, must also be using Spigot mappings, and your plugin manifest must indicate this.
Is there no real way to use this with a paper plugin and mojang mappings anymore?
This has never been possible, AnvilGUI has always used Spigot mappings. Mojang mappings are only available on modern Minecraft versions, and only on Paper servers. Going through the extra work of supporting both Spigot and Mojang mappings does not seem necessary especially because Paper plugins support using Spigot mappings, by setting paperweight-mappings-namespace: spigot in the manifest, as indicated by the Paper devs. Here is an example: https://docs.papermc.io/paper/dev/project-setup#spigot-mappings
No, there is no way to use spigot mappings for paper plugins. The server expects the paper plugin to use mojang mappings. So it needs an AnvilGUI API that has mojang mappings in it.
@mastercake10 I don't think this is true at all (see above)? Or have I misunderstood something? See here: https://docs.papermc.io/paper/dev/project-setup#spigot-mappings
All our plugins are paper-plugins and are paper only Reverting to spigot mappings, adding large amounts of load-time to servers, just for anvilgui isnt something we really want to do
I do understand why AnvilGUI cant, but in all reality majority of servers are swithing from Spigot So personally want to stay clear of "spigot" stuff or compatibility layers where possible
Ill look into the fork and see if that solves the problem for me 👍
@mastercake10 thank you worked perfectly 👍 , just had to add 1.21 compat
@mastercake10 I don't think this is true at all (see above)? Or have I misunderstood something? See here: https://docs.papermc.io/paper/dev/project-setup#spigot-mappings
Yeah, seems like I was wrong. But still why would people want to use spigot mappings in their paper plugin. I think maintaining both spigot and mojang mappings is feasible, since the mojang-mapped class for anvil gui can be reused over versions.
All our plugins are paper-plugins and are paper only Reverting to spigot mappings, adding large amounts of load-time to servers, just for anvilgui isnt something we really want to do
Then I do understand your concerns, although as far as I know, using Spigot-mapped plugins does not contribute in any significant way to load times, other than the first time you start the server, after which the server can just load cached Mojang-mapped versions of the plugin. Here is what the Paper devs have to say about it:
The .paper-remapped directory
As per the last announcement, we now use Mojang mappings at runtime and thus have to remap plugins that might still be using Spigot's mess of mappings. The
.paper-remappedfolder in the plugin directory caused a bit of confusion, so here's what it does: It stores the remapped plugin jars as well as a cached server jar, so that all of these don't have to be processed during every single server startup. The folder is automatically cleaned up, so you don't need to (and generally shouldn't) touch it.
In regards to the load times, I think maybe you have confused plugin remapping with plugin rewriting? The former was described above, and the latter is a totally different thing which does impact loading times, according to the Paper devs:
Slower than usual startup
In 1.20.5/6, Spigot has made additions to their plugin rewriting that resulted in poor startup performance, adding multiple seconds to each individual larger plugin. This has unfortunately been made slightly worse again in 1.21.
We have already mildly improved on it and are working on reducing it by as much as possible, but in the meantime you can work around it by disabling the cross-version compatibility measures by either optionally using Paper's plugin loader as a developer, or by using the
paper.disableOldApiSupportstartup flag. However, the flag will only work if all of your plugins are built against the latest API version.
Disabling this plugin rewriting is something that AnvilGUI may or may not support (I have not tested it), but that is a different question and the answer will be the same regardless of whether Spigot or Mojang mappings are used.
But still why would people want to use spigot mappings in their paper plugin.
For compatibility reasons, mostly. Honestly the choice between Spigot and Mojang mappings seems kind of arbitrary to me (from the perspective of the average plugin developer). Sure, if you are working with the server internals, Mojang mappings are great to have, but things can be remapped either way and most people are not working with internals, for good reason.
I think maintaining both spigot and mojang mappings is feasible, since the mojang-mapped class for anvil gui can be reused over versions.
Fair point, and I do agree that it may be feasible, I just don't think it's very necessary. Even if the Mojang mappings don't change as often, supporting them in addition to the Spigot mappings is extra work and makes the code more complicated.
Maybe consider adding to the README about this, and point out the remapping option and point to a fork for those who cant/wont use spigot mappings? Get not wanting to convert entire project for this alone, but documenting it is probably worth it ithink instead of leaving it behind a closed issue.
I could probably maintain a fork of @mastercake10 fork on my repo that works with paper-mappings unless he plans to maintainthe one he has on his repo 👍
I am using my fork in my plugins (the no_relocation branch), so you can expect that I will keep maintaining that fork.
Fair point, and I do agree that it may be feasible, I just don't think it's very necessary. Even if the Mojang mappings don't change as often, supporting them in addition to the Spigot mappings is extra work and makes the code more complicated.
It is necessary to have mojang mappings in the repo, since people are using paper plugins and/or don't want to use spigot mappings. We don't want to rely on the remapper, it takes some time to remap spigot to mojang as Boy0000 mentioned.
Supporting two mappings isn't really a problem, we can keep all the "legacy" NMS spigot mapped modules for versions < 1.20.5 and for the NMS modules from 1.20.6 on use the paper mappings. This is what I already do in my fork. It uses the paperweight-userdev gradle plugin, so we can aswell generate a jar file with the spigot-mapped sources using the userdev plugin. This would generate a jar file with everything spigot-mapped.
From this point on we can build artifacts containing only spigot mapped classes, only mojang mapped classes and a combination of both. Devs who want to target the paper platform can use the mojang-mapped artifact, and those who want to support both spigot and paper the combinated version.