You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if you exclude logback-classic in gradle because you want to use log4j2 you get an exception on start
2021-11-26 08:55:04.694 UTC|${sys:mea.location}|ERROR| c.h.u.UncaughtExceptionHandler:32 Uncaught exception in thread 'embedded-hivemq-state-change-executor'.
java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
at com.hivemq.HiveMQServer.bootstrap(HiveMQServer.java:109) ~[hivemq-community-edition-embedded-2021.3.jar:2021.3]
at com.hivemq.embedded.internal.EmbeddedHiveMQImpl.stateChange(EmbeddedHiveMQImpl.java:147) ~[hivemq-community-edition-embedded-2021.3.jar:2021.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.joran.spi.JoranException
at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[?:?]
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
... 5 more
if you use logback-classic and log4j2 you get
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/repo/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.14.1/9a40554b8dab7ac9606089c87ae8a5ba914ec932/log4j-slf4j-impl-2.14.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/repo/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
2021-11-26 09:00:02.833 UTC|${sys:mea.location}|INFO | c.h.e.i.EmbeddedHiveMQImpl:75 Setting default authentication behavior to ALLOW ALL
2021-11-26 09:00:08.360 UTC|${sys:mea.location}|INFO | c.h.e.i.EmbeddedHiveMQImpl:141 Starting EmbeddedHiveMQ.
2021-11-26 09:00:08.374 UTC|${sys:mea.location}|INFO | c.h.c.i.SystemInformationImpl:146 HiveMQ version: 2021.3
Exception in thread "main" java.util.concurrent.CompletionException: java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory and ch.qos.logback.classic.LoggerContext are in unnamed module of loader 'app')
at java.base/java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:412)
at java.base/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2044)
at hivemq.EmbeddedBroker.main(EmbeddedBroker.java:33)
Caused by: java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory and ch.qos.logback.classic.LoggerContext are in unnamed module of loader 'app')
at com.hivemq.bootstrap.LoggingBootstrap.getRootLogger(LoggingBootstrap.java:145)
at com.hivemq.bootstrap.LoggingBootstrap.prepareLogging(LoggingBootstrap.java:67)
at com.hivemq.HiveMQServer.bootstrap(HiveMQServer.java:109)
at com.hivemq.embedded.internal.EmbeddedHiveMQImpl.stateChange(EmbeddedHiveMQImpl.java:147)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
I think closing this ticket and only saying "We do not support Log4j2" is the wrong way to go. The solution is to depend on slf4j-api and not a specific implementation of slf4j (e.g. Logback or Log4j2).
Hi @Zomis - that's a fair point. Now that the request is filed in #366 and linked here - we'll make sure to update both issues once any updates happen.
Apologies for the brevity in closing this issue previously without a proper explanation.
Expected behavior
Log4j 2 SLF4J Binding can be used for SLF4J API
Actual behavior
if you exclude logback-classic in gradle because you want to use log4j2 you get an exception on start
if you use logback-classic and log4j2 you get
To Reproduce
Steps
Use embedded broker example found on this site
Reproducer code
build.gradle
Details
The text was updated successfully, but these errors were encountered: