Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade slf4j to 2.0.0 #11400

Closed
mrooneytrimble opened this issue Sep 3, 2022 · 7 comments · Fixed by #11433
Closed

Upgrade slf4j to 2.0.0 #11400

mrooneytrimble opened this issue Sep 3, 2022 · 7 comments · Fixed by #11433
Milestone

Comments

@mrooneytrimble
Copy link

slf4j has recently been upgraded by a major version, in order to use current versions of dependent libraries (logback-core, logback-classic) we need playframework to upgrade the version of slf4j to 2.0.0 as well.

Play Version

2.8.16

API

scala

Operating System

Mac

JDK

Library Dependencies

logback-classic, logback-core 1.4.0

Expected Behavior

The server is able to initialise

Actual Behavior

The server cannot startup because the version of slf4j is incompatible

[error] java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
[error] 	at play.api.libs.logback.LogbackLoggerConfigurator.loggerFactory(LogbackLoggerConfigurator.scala:21)
[error] 	at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:84)
[error] 	at play.api.libs.logback.LogbackLoggerConfigurator.init(LogbackLoggerConfigurator.scala:31)
[error] 	at play.core.server.DevServerStart$.$anonfun$mainDev$1(DevServerStart.scala:106)
[error] 	at play.utils.Threads$.withContextClassLoader(Threads.scala:22)
[error] 	at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:76)
[error] 	at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
[error] 	at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[error] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[error] 	at play.runsupport.Reloader$.startDevMode(Reloader.scala:306)
[error] 	at play.sbt.run.PlayRun$.devModeServer$lzycompute$1(PlayRun.scala:100)
[error] 	at play.sbt.run.PlayRun$.devModeServer$1(PlayRun.scala:83)
[error] 	at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:107)
[error] 	at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:67)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
[error] 	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
[error] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
[error] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
[error] 	at play.api.libs.logback.LogbackLoggerConfigurator.loggerFactory(LogbackLoggerConfigurator.scala:21)
[error] 	at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:84)
[error] 	at play.api.libs.logback.LogbackLoggerConfigurator.init(LogbackLoggerConfigurator.scala:31)
[error] 	at play.core.server.DevServerStart$.$anonfun$mainDev$1(DevServerStart.scala:106)
[error] 	at play.utils.Threads$.withContextClassLoader(Threads.scala:22)
[error] 	at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:76)
[error] 	at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
[error] 	at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[error] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[error] 	at play.runsupport.Reloader$.startDevMode(Reloader.scala:306)
[error] 	at play.sbt.run.PlayRun$.devModeServer$lzycompute$1(PlayRun.scala:100)
[error] 	at play.sbt.run.PlayRun$.devModeServer$1(PlayRun.scala:83)
[error] 	at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:107)
[error] 	at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:67)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
@PromanSEW
Copy link
Contributor

See #11399

@mkurz
Copy link
Member

mkurz commented Sep 5, 2022

Let's assign 2.9.0. @jfsoul @mrooneytrimble Do you have time to work on this and provide a pull request?
BTW: I would not upgrade in the 2.8.x branch, to not break anything, but maybe it would be possible to adjust code so at least it would be possible to upgrade by hand when using Play 2.8. Not sure though if that works.

@benthecarman
Copy link

benthecarman commented Sep 7, 2022

is there a way to resolve this?

Edit: was able to fix using dependencyOverrides

https://github.com/benthecarman/OP-RETURN-Bot/blob/8d3205916b4bc9a4b6ed15281b6930c85ae79d53/build.sbt#L34

@jfsoul
Copy link
Contributor

jfsoul commented Sep 8, 2022

@mkurz I had a quick look and I'm wondering whether we can resolve on 2.8.x fairly simply after all.

In 2.8.x...jfsoul:playframework:2.8.x if we replace the direct reference to StaticLoggerBinder with call to the factory method, then we should be able to work with SLF4J 1 or 2 because the factory finds the logging backend for us.

It looks like that used to be the way it was done until this change although I don't understand the reason for changing to use StaticLoggerBinder directly, so I'm a little hesitant.

I can spend a bit more time on it and PR, if this sounds reasonable.

@wsargent
Copy link
Member

The StaticLoggerBinder isn't significant -- a reference to LoggerFactory.getILoggerFactory() will work just as well.

@mkurz
Copy link
Member

mkurz commented Sep 12, 2022

Thanks @jfsoul, can you provide a pull request with your change?

@mkurz
Copy link
Member

mkurz commented Sep 20, 2022

Unfortunately two tests are failing when upgrading to slf4j v2, someone wants to help and take a look? For details see: #11419 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants