Grakkit plugin failing in spigot/paper 1.18.1 when trying to access JavaScript
wwlib opened this issue ยท 10 comments
It seems that spigot/paper 1.18.1 loads classes differently and is causing plugins that use JavaScript (ScriptCraft, Grakkit) to fail.
grakkit-5.0.4.paper.jar generates this error on server start:
[21:32:21] [Server thread/WARN]: [grakkit] Task #2 for grakkit v5.0.4 generated an exception
java.lang.NullPointerException: Cannot invoke "grakkit.FileInstance.tick()" because "grakkit.Grakkit.driver" is null
at grakkit.Grakkit.tick(Grakkit.java:93) ~[grakkit-5.0.4.paper.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftTask.run(CraftTask.java:82) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3405-Spigot-f4ff00f-d10c35e]
There is more info in this hub.spigotmc.org ticket: https://hub.spigotmc.org/jira/browse/SPIGOT-6902
Per md_5:
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Release notes: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
Btw: Tried loading Nashorn 15.3 as a module. It also works in 1.17.1 but not 1.18.1.
More info here:
https://github.com/wwlib/docker-minecraft/tree/master/minecraft-server-1.18.1-openjdk17
Especially odd because Grakkit doesn't use ScriptEngine, it packages the GraalJS library and imports those classes -- Grakkit is not a Nashorn-dependant plugin. I feel this issue may have some other cause, we've seen the error before in older versions.
If grakkit.Grakkit.driver
is null, the main instance isn't being initialized. I will look into this to see what can be done.
Grakkit should work flawlessly on 1.18+. I agree with hb, it definitely looks like there's a different issue at play here.. I would recommend checking if the plugins/grakkit and grakkit/index.js files exist and have appropriate permissions, and additionally make sure you're using the default java 17+ jdk if you're currently using something like GraalVM (ironically enough, Grakkit has had mixed success when the server starts from it).
Keep us posted!
It does work flawlessly with the spigot-1.17.1.jar and paper-1.17.1.jar. However, using the spigot-1.18.1.jar generates the error(s) - with the same index.js, plugin, etc.
I am curious to to know it you are using it successfully with 1.18.1 ?
If you can see https://hub.spigotmc.org/jira/browse/SPIGOT-6902 there is a discussion of a change in the way plugins and their dependencies are loaded between 1.17.1 and 1.18.1 which may explain the error(s).
There is also a newly opened bug related to the plugin class loader: https://hub.spigotmc.org/jira/browse/SPIGOT-6904
- [ "Especially odd because Grakkit doesn't use ScriptEngine, it packages the GraalJS library and imports those classes" ]
That's cool!
Ah, using GraalVM as your JVM is the actual issue here. As counter-intuitive as it sounds, Grakkit and GraalVM are incompatible. You have to run Grakkit on JDK.
OK. As you suggested, with openjdk:17-oraclelinux8 & paper-1.18.1-155.jar Grakkit works.
[02:10:43 INFO]: This server is running Paper version git-Paper-155 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 99cf01f)
So it looks like I stumbled onto a conflict between ghcr.io/graalvm/graalvm-ce:java17-21.3 & paper-1.18.1-155.jar
Explanation: Grakkit packages Graal JS engine in the JAR, when it patches those classes into the classloader it can conflict with GraalVM's existing set of GraalJS classes which cancel each other out.
OK. Thanks!
The fact that it works using spigot-1.17.1 but not 1.18.1 made it seem like it might be related to the ScriptEngine issue.
But now that I understand Grakkit better I like its approach vs. using ScriptEngine