question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing and using Java Libraries in lib-custom results in NoClassDefFoundError in 1.18

See original GitHub issue

Hello,

after rigorously trying to fix the issue and comparing self-built 1.17 and 1.18 server and plugin jars, it seems to strongly indicate that importing jar libraries into Jython does not seem to work. I have tried multiple libaries; ones, that can not possible have been broken by the upgrade to 1.18, but it always results in the same error.

E.g. putting the PlayerBorderAPI into /plugins and /lib-custom, and running the following code

from com.github.zandy.playerborderapi.api import PlayerBorderAPI

results in this being shown:

[20:57:47] [Server thread/WARN]: Traceback (most recent call last):
[20:57:47] [Server thread/WARN]:   File "C:\Users\Administrator\Desktop\Work In Progress Project\paper 1.18.2\.\python-plugins\pluginloader.py", line 154, in <module>
[20:57:47] [Server thread/WARN]:     loadPlugins()
[20:57:47] [Server thread/WARN]:   File "C:\Users\Administrator\Desktop\Work In Progress Project\paper 1.18.2\.\python-plugins\pluginloader.py", line 115, in loadPlugins
[20:57:47] [Server thread/WARN]:     loadPlugin(filename[:-3], [], loaded_plugins)
[20:57:47] [Server thread/WARN]:   File "C:\Users\Administrator\Desktop\Work In Progress Project\paper 1.18.2\.\python-plugins\pluginloader.py", line 115, in loadPlugins
[20:57:47] [Server thread/WARN]:     loadPlugin(filename[:-3], [], loaded_plugins)
[20:57:47] [Server thread/WARN]:   File "C:\Users\Administrator\Desktop\Work In Progress Project\paper 1.18.2\.\python-plugins\pluginloader.py", line 79, in loadPlugin
[20:57:47] [Server thread/WARN]:     execfile(pluginname + ".py", globals())
[20:57:47] [Server thread/WARN]:   File "socialscoreboard.py", line 224, in <module>
[20:57:47] [Server thread/WARN]:     from com.github.zandy.playerborderapi.api import PlayerBorderAPI
[20:57:47] [Server thread/WARN]: java.lang.NoClassDefFoundError: org/bukkit/plugin/Plugin
[20:57:47] [Server thread/WARN]:        at java.base/java.lang.Class.forName0(Native Method)
[20:57:47] [Server thread/WARN]:        at java.base/java.lang.Class.forName(Class.java:467)
[20:57:47] [Server thread/WARN]:        at org.python.core.Py.loadAndInitClass(Py.java:1160)
[20:57:47] [Server thread/WARN]:        at org.python.core.Py.findClassInternal(Py.java:1095)
[20:57:47] [Server thread/WARN]:        at org.python.core.Py.findClassEx(Py.java:1147)
[20:57:47] [Server thread/WARN]:        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:233)
[20:57:47] [Server thread/WARN]:        at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:36)
[20:57:47] [Server thread/WARN]:        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:221)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyObject.__findattr__(PyObject.java:902)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyObject.__findattr__(PyObject.java:889)
[20:57:47] [Server thread/WARN]:        at org.python.core.imp.ensureFromList(imp.java:1484)
[20:57:47] [Server thread/WARN]:        at org.python.core.imp.ensureFromList(imp.java:1449)
[20:57:47] [Server thread/WARN]:        at org.python.core.imp.import_module_level(imp.java:1377)
[20:57:47] [Server thread/WARN]:        at org.python.core.imp.importName(imp.java:1528)
[20:57:47] [Server thread/WARN]:        at org.python.core.ImportFunction.__call__(__builtin__.java:1285)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyObject.__call__(PyObject.java:433)
[20:57:47] [Server thread/WARN]:        at org.python.core.__builtin__.__import__(__builtin__.java:1232)
[20:57:47] [Server thread/WARN]:        at org.python.core.imp.importFromAs(imp.java:1620)
[20:57:47] [Server thread/WARN]:        at org.python.core.imp.importFrom(imp.java:1595)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx4.f$0(socialscoreboard.py:271)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx4.call_function(socialscoreboard.py)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyTableCode.call(PyTableCode.java:173)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyCode.call(PyCode.java:18)
[20:57:47] [Server thread/WARN]:        at org.python.core.Py.runCode(Py.java:1687)
[20:57:47] [Server thread/WARN]:        at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
[20:57:47] [Server thread/WARN]:        at org.python.core.__builtin__.execfile(__builtin__.java:512)
[20:57:47] [Server thread/WARN]:        at org.python.core.__builtin__.execfile(__builtin__.java:539)
[20:57:47] [Server thread/WARN]:        at org.python.core.BuiltinFunctions.__call__(__builtin__.java:144)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyObject.__call__(PyObject.java:481)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx0.loadPlugin$7(C:/Users/Administrator/Desktop/Work In Progress Project/paper 1.18.2/./python-plugins/pluginloader.py:93)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx0.call_function(C:/Users/Administrator/Desktop/Work In Progress Project/paper 1.18.2/./python-plugins/pluginloader.py)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyTableCode.call(PyTableCode.java:173)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyBaseCode.call(PyBaseCode.java:168)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyFunction.__call__(PyFunction.java:437)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx0.loadPlugins$10(C:/Users/Administrator/Desktop/Work In Progress Project/paper 1.18.2/./python-plugins/pluginloader.py:140)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx0.call_function(C:/Users/Administrator/Desktop/Work In Progress Project/paper 1.18.2/./python-plugins/pluginloader.py)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyTableCode.call(PyTableCode.java:173)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyBaseCode.call(PyBaseCode.java:119)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyFunction.__call__(PyFunction.java:406)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx0.f$0(C:/Users/Administrator/Desktop/Work In Progress Project/paper 1.18.2/./python-plugins/pluginloader.py:156)
[20:57:47] [Server thread/WARN]:        at org.python.pycode._pyx0.call_function(C:/Users/Administrator/Desktop/Work In Progress Project/paper 1.18.2/./python-plugins/pluginloader.py)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyTableCode.call(PyTableCode.java:173)
[20:57:47] [Server thread/WARN]:        at org.python.core.PyCode.call(PyCode.java:18)
[20:57:47] [Server thread/WARN]:        at org.python.core.Py.runCode(Py.java:1687)
[20:57:47] [Server thread/WARN]:        at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
[20:57:47] [Server thread/WARN]:        at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:287)
[20:57:47] [Server thread/WARN]:        at com.macuyiko.minecraftpyserver.jython.JyInterpreter.execfile(JyInterpreter.java:128)
[20:57:47] [Server thread/WARN]:        at com.macuyiko.minecraftpyserver.MinecraftPyServerPlugin.startPluginInterpreters(MinecraftPyServerPlugin.java:123)
[20:57:47] [Server thread/WARN]:        at com.macuyiko.minecraftpyserver.MinecraftPyServerPlugin.onEnable(MinecraftPyServerPlugin.java:58)
[20:57:47] [Server thread/WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
[20:57:47] [Server thread/WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342)
[20:57:47] [Server thread/WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480)
[20:57:47] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:518)
[20:57:47] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:432)
[20:57:47] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612)
[20:57:47] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414)
[20:57:47] [Server thread/WARN]:        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:263)
[20:57:47] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1007)
[20:57:47] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304)
[20:57:47] [Server thread/WARN]:        at java.base/java.lang.Thread.run(Thread.java:833)
[20:57:47] [Server thread/WARN]: Caused by: java.lang.ClassNotFoundException: org.bukkit.plugin.Plugin
[20:57:47] [Server thread/WARN]:        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
[20:57:47] [Server thread/WARN]:        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
[20:57:47] [Server thread/WARN]:        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
[20:57:47] [Server thread/WARN]:        ... 61 more
[20:57:47] [Server thread/WARN]: java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/bukkit/plugin/Plugin

From this post it seems, that in Java 17 the way Reflections work has changed. Though I have not looked into how this plugin functions, but maybe that could be a hint?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Macuyikocommented, May 16, 2022

Should be fixed in the latest release. Reflections and JDK 17+ was already fixed previously. The problem was due to the way how Spigot now handles its own JARs/libraries.

0reactions
MuffinMariocommented, May 22, 2022

For now, it seems that everything is working. Thank you for your quick responses and cooperation!

Read more comments on GitHub >

github_iconTop Results From Across the Web

android: Java .jar library import resulting in a java.lang. ...
I've been building a custom Java library, and after importing it to my Android project, it results in a java.lang.NoClassDefFoundError when I ...
Read more >
How to Resolve the NoClassDefFoundError in Java
NoClassDefFoundError is a Java error that occurs when the JVM is unable to find a class at runtime which was available at compile-time....
Read more >
3 ways to solve java.lang.NoClassDefFoundError in Java ...
If you are using a shared library which is shared among multiple application which runs under different users then you may run into...
Read more >
[1.12.2] Library only working on runServer/runClient (java.lang ...
Hello, I am using a Discord Library in my mod and everything is working fine while using the gradle launch functions.
Read more >
Import of Word doc - caused by: java.lang.NoClassD...
NoClassDefFoundError : com.atlassian.plugins.conversion.Asp ... please share with us the following results of these SQL queries from the Confluence database.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found