PatchBukkit icon indicating copy to clipboard operation
PatchBukkit copied to clipboard

[Bug] PatchBukkitPluginClassLoader does not provide CodeSource location

Open zKOSMOSz opened this issue 1 month ago • 0 comments

Prerequisites

  • [x] I am using the latest git commit of PatchBukkit on my server
  • [x] I am using the latest git commit of Pumpkin-MC as my server

Plugin
Oraxen (https://github.com/oraxen/oraxen)
Version tested: 1.220.1

Logs / Error Messages

2026-10-25 13:37:06 ERROR Error occurred while enabling Oraxen v1.220.1 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "java.net.URL.toURI()" because the return value of "java.security.CodeSource.getLocation()" is null
        at io.th0rgal.oraxen.configs.ResourcesManager.browseJar(ResourcesManager.java:125)
        at io.th0rgal.oraxen.configs.ResourcesManager.extractConfigsInFolder(ResourcesManager.java:65)
        at io.th0rgal.oraxen.configs.ConfigsManager.validatesConfig(ConfigsManager.java:165)
        at io.th0rgal.oraxen.OraxenPlugin.reloadConfigs(OraxenPlugin.java:279)
        at io.th0rgal.oraxen.OraxenPlugin.onEnable(OraxenPlugin.java:113)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:280)
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:201)
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:519)
        at org.patchbukkit.loader.PatchBukkitBootstrap.bootstrapPlugins(PatchBukkitBootstrap.java:110)

Additional Notes

Oraxen (and many other plugins) tries to locate its own JAR via getProtectionDomain().getCodeSource().getLocation() in order to extract default configuration files from the JAR on first enable.

In a normal Paper/Spigot environment this works because PluginClassLoader extends URLClassLoader and properly sets the CodeSource with the plugin JAR URL.

Under PatchBukkit the custom PatchBukkitPluginClassLoader returns null from CodeSource.getLocation(), which causes the NPE.

This is a compatibility issue with any plugin that relies on CodeSource.getLocation() / JAR self-discovery for resource extraction.

Would be great if PatchBukkitPluginClassLoader could provide a proper CodeSource pointing to the plugin file (similar to how Bukkit’s PluginClassLoader does it).

zKOSMOSz avatar Oct 25 '26 14:10 zKOSMOSz