mcspring-boot
mcspring-boot copied to clipboard
/reload not working as expected
When I start the server, the plugin loads fine (now that the classloaders and shading is fixed), but when using /reload
I get the following exceptions:
[05:09:03 INFO]: 2019-06-01 05:09:03.290 INFO 25616 --- [ Server thread] c.github.cc007.headsplugin.HeadsPlugin : [HeadsPluginAPI] Disabling HeadsPluginAPI v2.0.0-SNAPSHOT
[05:09:03 INFO]: 2019-06-01 05:09:03.293 WARN 25616 --- [ Server thread] .s.c.a.CommonAnnotationBeanPostProcessor : Destroy method on bean with name 'org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration' threw an exception: java.lang.IllegalStateException: Failed to introspect Class [com.netflix.config.ConfigurationManager] from ClassLoader [org.bukkit.plugin.
java.PluginClassLoader@43d33e22]
[05:09:04 INFO]: Loaded 524 recipes
[05:09:04 INFO]: Reloading ResourceManager: Default, bukkit
[05:09:05 INFO]: Loaded 524 recipes
[05:09:07 INFO]: 2019-06-01 05:09:07.463 INFO 25616 --- [ Server thread] c.github.cc007.headsplugin.HeadsPlugin : [HeadsPluginAPI] Loading HeadsPluginAPI v2.0.0-SNAPSHOT
[05:09:07 INFO]: 2019-06-01 05:09:07.471 INFO 25616 --- [ Server thread] c.github.cc007.headsplugin.HeadsPlugin : [HeadsPluginAPI] Enabling HeadsPluginAPI v2.0.0-SNAPSHOT
[05:09:08 INFO]: 2019-06-01 05:09:08.864 WARN 25616 --- [ Server thread] org.springframework.boot.ResourceBanner : Banner not printable: class path resource [banner.txt] (class java.io.FileNotFoundException: 'class path resource [banner.txt] cannot be opened because it does not exist')
java.io.FileNotFoundException: class path resource [banner.txt] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.ResourceBanner.printBanner(ResourceBanner.java:64) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplicationBannerPrinter$Banners.printBanner(SpringApplicationBannerPrinter.java:142) [HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplicationBannerPrinter.print(SpringApplicationBannerPrinter.java:71) [HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.printBanner(SpringApplication.java:575) [HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:309) [HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at com.github.cc007.headsplugin.HeadsPlugin.onEnable(HeadsPlugin.java:29) [HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:265) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:347) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:410) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugin(CraftServer.java:436) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugins(CraftServer.java:350) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.reload(CraftServer.java:809) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.Bukkit.reload(Bukkit.java:604) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:28) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchCommand(CraftServer.java:704) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchServerCommand(CraftServer.java:689) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.DedicatedServer.handleCommandQueue(DedicatedServer.java:459) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:418) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:831) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:729) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
[05:09:08 INFO]: 2019-06-01 05:09:08.873 INFO 25616 --- [ Server thread] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
[05:09:08 INFO]: 2019-06-01 05:09:08.974 WARN 25616 --- [ Server thread] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.github.cc007.headsplugin.config.Application]; nested exception is java.io.F
ileNotFoundException: class path resource [com/github/cc007/headsplugin/business/services/chat/ChatManager.class] cannot be opened because it does not exist
[05:09:08 INFO]: 2019-06-01 05:09:08.980 ERROR 25616 --- [ Server thread] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.github.cc007.headsplugin.config.Application]; nested exception is java.io.FileNotFoundException: class path resource [com/github/cc007/headsplugin/business/services/chat/ChatManager.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at com.github.cc007.headsplugin.HeadsPlugin.onEnable(HeadsPlugin.java:29) [HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:265) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:347) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:410) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugin(CraftServer.java:436) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugins(CraftServer.java:350) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.reload(CraftServer.java:809) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.Bukkit.reload(Bukkit.java:604) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:28) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchCommand(CraftServer.java:704) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchServerCommand(CraftServer.java:689) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.DedicatedServer.handleCommandQueue(DedicatedServer.java:459) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:418) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:831) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:729) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
Caused by: java.io.FileNotFoundException: class path resource [com/github/cc007/headsplugin/business/services/chat/ChatManager.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:88) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:75) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:190) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:295) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
... 26 common frames omitted
[05:09:08 INFO]: 2019-06-01 05:09:08.984 ERROR 25616 --- [ Server thread] Minecraft : Error occurred while enabling HeadsPluginAPI v2.0.0-SNAPSHOT (Is it up to date?)
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.github.cc007.headsplugin.config.Application]; nested exception is java.io.FileNotFoundException: class path resource [com/github/cc007/headsplugin/business/services/chat/ChatManager.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at com.github.cc007.headsplugin.HeadsPlugin.onEnable(HeadsPlugin.java:29) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:265) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:347) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:410) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugin(CraftServer.java:436) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugins(CraftServer.java:350) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.reload(CraftServer.java:809) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.Bukkit.reload(Bukkit.java:604) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:28) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchCommand(CraftServer.java:704) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchServerCommand(CraftServer.java:689) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.DedicatedServer.handleCommandQueue(DedicatedServer.java:459) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:418) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:831) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:729) [spigot.jar:git-Spigot-1a3504a-dfa7583]
at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
Caused by: java.io.FileNotFoundException: class path resource [com/github/cc007/headsplugin/business/services/chat/ChatManager.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:88) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:75) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:190) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:295) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) ~[HeadsPluginAPI-2.0.0-SNAPSHOT.jar:na]
... 26 common frames omitted
[05:09:08 INFO]: 2019-06-01 05:09:08.993 INFO 25616 --- [ Server thread] Minecraft : Server permissions file permissions.yml is empty, ignoring it
My guess is that the classloader is not properly restored at the onDisable
hook, my test plugins works fine with:
@Override
public void onDisable() {
try {
if (context != null) {
context.close();
}
} finally {
context = null;
Thread.currentThread().setContextClassLoader(defaultClassLoader);
}
}
Can you verify this?
If this is not the case, you can also restore the default classloader right after the application startup:
@Override
public void onEnable() {
try {
// app startup
} finally {
Thread.currentThread().setContextClassLoader(defaultClassLoader);
}
}
The bukkit plugin reloading system is a mystery, so it's hard to deduce the problem.
My code looks the same, except for the try/finally usage, but that should only matter if an exception is actually thrown durind the on disable.
The only difference is that I change the class loader before starting the spring application, because it needs to be set before feign is initialized
I still don't know what the cause of this problem, maybe something caused by the classloader, but no clue about exactly what it is. Can you reproduce the problem without the feign client?
I'll try that once I have time
Have you tried look into certain beans that get their close
or destroy
method automatically called when destroyed? If this happens to bukkit, of course it would close the server.
Can you reproduce this bug in the latest version with SpringSpigotBootstrapper
? (0.20.7)
It now starts the spring context in a different thread, without having to change the context class loader of the main one, this can solve other problems too.
I might have accidentally fixed this by using a compound classloader. I need to test this a bit further, because there are other issues during the restart (my database lockfile is causing problems, see CC007/HeadsPluginAPI#8). If I'm still experiencing issues with restart after fixing those, I'll give the SpringSpigotBootstrapper a try.