GlowstoneMC / Glowstone

A fast, customizable and compatible open source server for Minecraft: Java Edition
https://glowstone.net
Other
1.89k stars 271 forks source link

Not using Log4j breaks plugins #500

Closed alula closed 7 years ago

alula commented 7 years ago

Glowstone build: every? (tested on #550 and #551)

Glowstone doesn't contain Log4j so it breaks many plugins, even mine, so i had to write an server engine detector.

02:21:46 [SEVERE] Error occurred while enabling NekoooGuilds v0.0.1 (Is it up to date?)
java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
    at gabixdev.nekoooguilds.NekoooGuilds.onEnable(NekoooGuilds.java:114)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:316)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:411)
    at net.glowstone.GlowServer.enablePlugins(GlowServer.java:939)
    at net.glowstone.GlowServer.start(GlowServer.java:630)
    at net.glowstone.GlowServer.run(GlowServer.java:452)
    at net.glowstone.GlowServer.main(GlowServer.java:322)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:102)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:87)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 8 more
02:21:46 [INFO] [NekoooGuilds] Disabling NekoooGuilds v0.0.1

Plugin src if you want: https://github.com/gabixdev/NekoooGuilds

mastercoms commented 7 years ago

It can be added to the library manager for now?

sgdc3 commented 7 years ago

Usually plugin interact with log4j in order to filter the console output, adding the library would fix the CNFE but is not going to emulate the expected behaviour.

sgdc3 commented 7 years ago

What about that? https://logging.apache.org/log4j/2.0/log4j-to-slf4j/index.html

mastercoms commented 7 years ago

Glowstone uses jul.

Also this expected behavior is implementation specific, so I don't think we should worry about it. It restricts what we want for our logging system. Though, it is up to @momothereal to decide what logging system we should use.

Adding the library is sufficient I think, since it will allow the plugin to load.

sgdc3 commented 7 years ago

Uh, i thought slf4j was a standard nowadays xD

mastercoms commented 7 years ago

Yeah but doesn't vanilla use slf4j-jdk14? So we would have to lose performance if we wanted to support it, and lose even more if we wanted to use logback and then still support vanilla's logging system.

gdude2002 commented 7 years ago

I think this is tricky as there are definitely solid use-cases for manipulating the loggers in a cross-server way.

For example, there are Discord plugins that use log4j to send server console output to Discord. That's not going to work on Glowstone.

sgdc3 commented 7 years ago

Also authme or other auth plugins need to hide user passwords from console.

Foorack commented 7 years ago

@sgdc3 Why? If a server owner wanted to access people's passwords then they easily could even if they weren't visible in console. 🤔

gdude2002 commented 7 years ago

Could they? Are you sure about that? :P

I suppose you could if you were intercepting commands manually, but aside from that, I'd hope they were hashed..

Scarsz commented 7 years ago

@gdude2002 he's talking about the login command. When a player joins, they have to issue a command to authorize themselves- that command contains their password. /login mysuperlongpassword

Foorack commented 7 years ago

@gdude2002 Any simple command logger plugin should do. ☺️

gdude2002 commented 7 years ago

That would count as intercepting commands. :P

sgdc3 commented 7 years ago

@Foorack a bad server owner ;)

yangm97 commented 7 years ago

So I’m new to glowstone, searched for “authme” on the issue tracker then I saw this. Does that mean the most popular authentication plugin for spigot doesn’t work on glowstone simply because of a log driver issue?

gdude2002 commented 7 years ago

I'm pretty sure you can still do that stuff with jul, you'd just have to support it explicitly.

Also if the issue was really actually simple then it would probably be fixed by now :P

yangm97 commented 7 years ago

I was not clear enough ¯\(ツ)/¯ I was asking as an user “if I drop this to the plugin folder will it work even without author changing stuff?” as in “damn, I need to ask every plugin author to fix something so small on their end”. Sorry if it felt like I was calling the issue on the Glowstone end simple.

gdude2002 commented 7 years ago

I have no idea - I don't see it on the plugin compatibility table. Why not try it and report back?

mastercoms commented 7 years ago

The ClassNotFoundException should definitely be fixed, and it will be a simple fix on Glowstone's part.

yangm97 commented 7 years ago

Tried running AuthMe with the latest commit from master (bf69637286e428c15955887c8683d661696f3050), got the same error as the OP:

01:42:09 [INFO] [AuthMe] Enabling AuthMe v5.3.2-b1726
01:42:09 [WARNING] [AuthMe] Aborting initialization of AuthMe: [NoClassDefFoundError]: org/apache/logging/log4j/core/Filter
01:42:09 [WARNING] [AuthMe] THE SERVER IS GOING TO SHUT DOWN AS DEFINED IN THE CONFIGURATION!
01:42:09 [INFO] [AuthMe] Waiting for 0 tasks to finish
01:42:09 [INFO] [AuthMe] AuthMe 5.3.2-b1726 disabled!
01:42:09 [INFO] The server is shutting down...
01:42:09 [INFO] Saving world: world
01:42:11 [INFO] Saving world: world_nether
01:42:13 [INFO] Saving world: world_the_end
01:42:13 [SEVERE] Error during server startup.
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@30b1c5d5 rejected from java.util.concurrent.ScheduledThreadPoolExecutor@3e2d65e1[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)
    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
    at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:326)
    at java.util.concurrent.ScheduledThreadPoolExecutor.scheduleAtFixedRate(ScheduledThreadPoolExecutor.java:573)
    at java.util.concurrent.Executors$DelegatedScheduledExecutorService.scheduleAtFixedRate(Executors.java:735)
    at net.glowstone.scheduler.GlowScheduler.start(GlowScheduler.java:81)
    at net.glowstone.GlowServer.start(GlowServer.java:632)
    at net.glowstone.GlowServer.run(GlowServer.java:452)
    at net.glowstone.GlowServer.main(GlowServer.java:322)
>%     
aramperes commented 7 years ago

@mastercoms The log says Aborting initialization of AuthMe: [NoClassDefFoundError]: org/apache/logging/log4j/core/Filter which is the reason the server shuts down in the first place.

E: comment was deleted

aramperes commented 7 years ago

Perhaps we are including the wrong library?

mastercoms commented 7 years ago

log4j-core-2.8.1.jar contains org/apache/logging/log4j/core/Filter.

mastercoms commented 7 years ago

I could not reproduce this error on Glowstone version 2017.8.1-SNAPSHOT.3b7499a-MC1.12.1.

14:36:02 [INFO] [AuthMe] Enabling AuthMe v5.3.2-b1726
14:36:02 [WARNING] ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging.
14:36:02 [INFO] [AuthMe] SQLite driver loaded
14:36:02 [INFO] [AuthMe] SQLite Setup finished
14:36:02 [INFO] [AuthMe] Hooked into Vault!
14:36:02 [INFO] [AuthMe] [LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com
14:36:02 [WARNING] [AuthMe] WARNING! The protectInventory feature requires ProtocolLib! Disabling it...
14:36:03 [INFO] [AuthMe] Development builds are available on our jenkins, thanks to f14stelt.
14:36:03 [INFO] [AuthMe] Do you want a good game server? Look at our sponsor GameHosting.it leader in Italy as Game Server Provider!
14:36:03 [INFO] [AuthMe] AuthMe 5.3.2 build n.1726 correctly enabled!

@yangm97 could you give the full log for server startup? and list files in the lib folder.

yangm97 commented 7 years ago

log-2017-08-11.txt

log4j-api-2.8.1.jar log4j-core-2.8.1.jar mysql-connector-java-5.1.42.jar sqlite-jdbc-3.16.1.jar

mastercoms commented 7 years ago

What are the file sizes for log4j-api-2.8.1.jar and log4j-core-2.8.1.jar?

yangm97 commented 7 years ago

32KB and 25KB

yangm97 commented 7 years ago

Huh, deleting the lib folder and letting it download the libraries again led to bigger, working files. Sorry for reopening this issue.

But I might suggest adding some checksum to these files, to make sure the server re-downloads them in case they get corrupt.

mastercoms commented 7 years ago

I have quite a few library manager improvements in the works, but I'm awaiting the Java 9 release for that.

These improvements will make the library manager much more robust, improve modularity and allow for better mod/plugin support enhanced by Shine.

aramperes commented 7 years ago

Closing this issue as the initial problem has been resolved -- other suggestions about the library manager, including checksums can be done in a new issue :)