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

Logging issue regarding EmbeddedHiveMQ in OSGi Environment #439

Closed
janosch24 opened this issue Dec 22, 2023 · 1 comment · Fixed by #510
Closed

Logging issue regarding EmbeddedHiveMQ in OSGi Environment #439

janosch24 opened this issue Dec 22, 2023 · 1 comment · Fixed by #510

Comments

@janosch24
Copy link
Contributor

janosch24 commented Dec 22, 2023

Problem or use case

Incorporating EmbeddedHiveMQ in OSGi environment (such as equinox) might lead to ClassCastException during LoggingBootstrap if logback based logging is already setup in OSGi.

!STACK 0
java.util.concurrent.CompletionException: java.lang.ClassCastException: class ch.qos.logback.classic.LoggerContext cannot be cast to class ch.qos.logback.classic.LoggerContext (ch.qos.logback.classic.LoggerContext is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @f14a7d4; ch.qos.logback.classic.LoggerContext is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @673d71d5)
	at java.base/java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:413)
	at java.base/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2118)
...
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:343)
Caused by: java.lang.ClassCastException: class ch.qos.logback.classic.LoggerContext cannot be cast to class ch.qos.logback.classic.LoggerContext (ch.qos.logback.classic.LoggerContext is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @f14a7d4; ch.qos.logback.classic.LoggerContext is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @673d71d5)
	at com.hivemq.bootstrap.LoggingBootstrap.getRootLogger(LoggingBootstrap.java:145)
	at com.hivemq.bootstrap.LoggingBootstrap.prepareLogging(LoggingBootstrap.java:67)
...

Obviously this seems to be a class loading issue in OSGi environment.
For a more detailed description, see this forum contribution.

Preferred solution or suggestions

From my point of view, two possible solutions are considerable:

  1. Add a new method to EmbeddedHiveMQBuilder to programmatically switch off logging
  2. Add a system property, such as hivemq.log.bootstrap.disabled to conditionally switch off logging

The latter one possibly might have less drawbacks regarding backward compatibility, as only class HiveMQServer has to get adjusted a little bit ...

@janosch24
Copy link
Contributor Author

PS.: If desired I can work on this issue ...

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.

1 participant