Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError on 1.20.6 #330

Closed
UsainSrht opened this issue May 27, 2024 · 31 comments
Closed

NoClassDefFoundError on 1.20.6 #330

UsainSrht opened this issue May 27, 2024 · 31 comments

Comments

@UsainSrht
Copy link

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();
                        }
                    }
                }
            }
        }
    }
@UsainSrht
Copy link
Author

AnvilGUI version: 1.9.4-SNAPSHOT
Heres the shade config
image

image

@mastercake10
Copy link
Contributor

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?

@UsainSrht
Copy link
Author

I am not using paperweight or any nms related things in those plugins.

@mastercake10
Copy link
Contributor

Check your server log file that your plugin gets remapped by paper.

@UsainSrht
Copy link
Author

Deleted the .paper-remapped folder and started the server again, both of my plugins didn't get remapped (SCClaims & SCCore)

@mastercake10
Copy link
Contributor

What are the contents of the MANIFEST.MF file in your plugin's .jar file?

@UsainSrht
Copy link
Author

UsainSrht commented May 27, 2024

Manifest-Version: 1.0
Created-By: Maven Jar Plugin 3.2.0
Build-Jdk-Spec: 21

@mastercake10
Copy link
Contributor

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.

@UsainSrht
Copy link
Author

yes both sccore and scclaims are in plugins folder, they have paper plugin.ymls also i just saw that mentioned in the other issue

@mastercake10
Copy link
Contributor

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

@UsainSrht
Copy link
Author

uhh how exactly? system scope?

@mastercake10
Copy link
Contributor

mastercake10 commented May 27, 2024

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

@UsainSrht
Copy link
Author

I mean, how is this possible?
image
image

@mastercake10
Copy link
Contributor

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>

@UsainSrht
Copy link
Author

Worked thanks. Are you guys going to publish a separate jar for mojang mappings?

@mastercake10
Copy link
Contributor

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.

@0dinD
Copy link
Collaborator

0dinD commented May 30, 2024

@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-namespace attribute in the manifest. Acceptable values are mojang, mojang+yarn (treated the same as mojang), or spigot.

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.

@WesJD
Copy link
Owner

WesJD commented Jun 30, 2024

@UsainSrht did the above solve your issue? if so we should add to README

@TrueMB
Copy link
Contributor

TrueMB commented Jul 6, 2024

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

@UsainSrht
Copy link
Author

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?

@mastercake10
Copy link
Contributor

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?

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.

@Boy0000
Copy link

Boy0000 commented Jul 25, 2024

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

@mastercake10
Copy link
Contributor

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 #330 (comment).

@0dinD
Copy link
Collaborator

0dinD commented Jul 25, 2024

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

@Boy0000
Copy link

Boy0000 commented Jul 25, 2024

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 👍

@Boy0000
Copy link

Boy0000 commented Jul 25, 2024

@mastercake10 thank you worked perfectly 👍 , just had to add 1.21 compat

image

@mastercake10
Copy link
Contributor

@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.

@0dinD
Copy link
Collaborator

0dinD commented Jul 25, 2024

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-remapped folder 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.disableOldApiSupport startup 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.

@Boy0000
Copy link

Boy0000 commented Jul 25, 2024

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 👍

@mastercake10
Copy link
Contributor

mastercake10 commented Jul 26, 2024

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.

@0dinD
Copy link
Collaborator

0dinD commented Aug 5, 2024

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.

Using Paper plugins alone is not a reason to use Mojang mappings, Spigot mappings can still be used in Paper plugins. I mean, I totally get that some might not want to use Spigot mappings, but so far I'm just haven't seen any compelling reason to put in the effort* of maintaining a more complex solution with combined mappings. The time that it takes to remap the plugin seems very negligible to me, especially because it only happens once, and the result is more or less permanently cached after that.

* Of course, if someone else is willing to put in that effort, then who am I to complain?


Maybe, if we're lucky, there is a future where we don't have to keep maintaining NMS version wrappers. In fact, I think it's fairly likely that it will happen. That would be really nice.

Anyways, I submitted a PR to document the Paper remapping stuff, see #345. Let me know if it looks good to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants