question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrade slf4j to 2.0.0

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mkurzcommented, Sep 12, 2022

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

1reaction
jfsoulcommented, 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 https://github.com/playframework/playframework/compare/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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SLF4J News
SLF4J version 2.0.0 requires Java 8. It builds on the 1.8.x series and adds a backward-compatible fluent logging api. By backward-compatible, we mean...
Read more >
Upgrade slf4j-api to 2.0 · Issue #1034 · slackapi/java-slack-sdk
slf4j project released a new major version - 2.0. According to the migration guide, it's safe to upgrade the dependency in this project...
Read more >
Is slf4j 2.0.0-alpha7 compatible with log4j 2.17.2?
0-alpha2 compatible with Log4j 2.8.2. I am trying to upgrade from slf4j 1.7.36 to 2.0.0-alpha7. Currently I have this in my POM:
Read more >
Log4j 2 SLF4J Binding - Apache Logging Services
The SLF4J binding provided in this component cause all the SLF4J APIs to be routed to Log4j 2. Simply include the Log4j 2...
Read more >
SLF4J 2.0.0 released : r/java - Reddit
SLF4J 2.0.0 released ... Looks like we finally have a stable version that supports modules. ... Read the announcement in the qos.ch-announce mailing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found