Sponge crashes on "Searching for plugins"


#1

I have a simple plugin that uses a library of mine as an external dependency. When I build a Jar that includes this library (and it’s dependencies) with Gradle Shadow plugin, sponge crashes when trying to search for plugins, with an IllegalArgumentException.

java.lang.IllegalArgumentException: null
	at org.objectweb.asm.ClassReader.<init>(Unknown Source) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.objectweb.asm.ClassReader.<init>(Unknown Source) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.objectweb.asm.ClassReader.<init>(Unknown Source) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.spongepowered.server.launch.plugin.PluginScanner.scanClassFile(PluginScanner.java:341) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.spongepowered.server.launch.plugin.PluginScanner.scanJar(PluginScanner.java:245) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.spongepowered.server.launch.plugin.PluginScanner.scanDirectory(PluginScanner.java:173) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.spongepowered.server.launch.plugin.VanillaLaunchPluginManager.findPlugins(VanillaLaunchPluginManager.java:66) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.spongepowered.server.launch.VanillaServerTweaker.searchPlugins(VanillaServerTweaker.java:171) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.spongepowered.server.launch.VanillaServerTweaker.injectIntoClassLoader(VanillaServerTweaker.java:94) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) ~[launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) ~[launchwrapper-1.12.jar:?]
	at org.spongepowered.server.launch.VanillaServerMain.main(VanillaServerMain.java:126) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]
	at org.spongepowered.server.launch.VersionCheckingMain.main(VersionCheckingMain.java:38) ~[spongevanilla-1.12.2-7.1.5.jar:1.12.2-7.1.5]

When I make a simple Jar without the deps, it loads the plugin (and I get a ClassNotFoundException, 'case the deps aren’t there)…

I’m absolutely clueless… Any ideas what could be causing this?

(my build.gradle file and the only class currently there)


#2

This is a guess, but it looks like you’re triggering this exception. Have you compiled your dependency using Java 9 or above? Sponge will only work with Java 8.

Entire debug logs would be helpful otherwise.


#3

Interesting, I believe I’ve compiled the plugin with Java 8, but I might have compiled the dependency with a newer version, I’ll take a look.

There are no further logs that would be of interest, this error is literally the only thing I got. The rest is just the usual Sponge stuff. (Whole log here if interested)


#4

So, I’ve tried recompiling the dependency with Java 8 just to be sure and I’m still getting the exact same error :confused:


#5

Bump?

Additional info:

  • Java runtime version: 1.8.0_191
  • Dependencies and plugin itself compiled with: 1.8.0_191
  • Sponge version: 1.12.2-7.1.5 (SpongeVanilla)

#6

It does look like the error is coming from a class compiled for a later version of java.

I see you’ve got sourceCompatibility = 1.8 in your build.gradle, I suggest adding targetCompatibility = 1.8 too.

To see if there are any classes compiled for a later version in the jar, you can use the javap tool (included in the JDK) to get the version information of a class.
Extract the class files from the jar and run javap -v on each of them, it outputs the version at the top.

I extracted the classes from your webcore dependency and it looks OK. Version 52 is Java 8 (see version numbers here: https://en.wikipedia.org/wiki/Java_class_file#General_layout)

$ find webcore-1.0-20190409.151532-2/ -name '*.class' -exec javap -v {} \+ | grep version | sort -u
  major version: 52
  minor version: 0