Now, the start() method throws me a ClassCastException during the LoggingBootstrap:
!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 OSGi uses seperate class loaders on a per bundle basis and I have already a bundle to setup logging (also backed by logback as HiveMQ does). Here I have some collisions regarding the casts done in the com.hivemq.bootstrap.LoggingBootstrap class.
As a workaround I commented all calls to com.hivemq.bootstrap.LoggingBootstrap in class com.hivemq.HiveMQServer’s bootstrap() method (only 3 places) to entirely disable the setup of any specific logging and this eventually worked!
So my questions are:
Does anyone have experience incorporating HiveMQ into OSGi environment?
Are there any arguments against deactivating logging as I did for my purpose?
And @ForumMaintainers: If there are no arguments against it, is it worth opening an Issue/Pull Request to get com.hivemq.embedded.EmbeddedHiveMQBuilder changed to programmatically deactivate logging during setup?
Thank you for reaching out, and we’re glad to hear that you were able to find a workaround for the logging issue in your OSGi environment. Your detailed explanation of the problem and the solution you implemented is greatly appreciated.
We understand the challenges that can arise when integrating HiveMQ into diverse environments, and your experience with OSGi sheds light on a potential improvement. Disabling logging programmatically, as you’ve done, seems like a viable workaround in your case.
We encourage you to contribute your insights by opening an Issue or Pull Request on our GitHub repository. This could be a valuable addition to the HiveMQ community, especially for users facing similar challenges in OSGi environments.
Your effort to share your experience and suggest a solution is highly commendable, and we welcome any contributions that enhance the overall usability of HiveMQ. If you decide to proceed with a Pull Request, our development team will thoroughly review it to ensure compatibility and coherence with the project’s goals.
Once again, thank you for bringing this to our attention, and we appreciate your proactive approach to finding solutions. If you have any further questions or need assistance during the contribution process, feel free to reach out.
Hi @Daria_H,
thank you very much for your reply.
I will open Issue/pull request asap.
My plan is to incorporate EmbeddedHiveMQBuilder to programmatically switch off logging.
Meanwhile I have my changes in production since a few month.
No issues, works like a charm …
Thanks again for your advice!
Best regards,
janosch
Has there been any progress on this problem? I have the same issue. I’m not using OSGi, but I have an embedded HiveMQ instance running inside a Spring Boot application. HiveMQ and Spring Boot clash since they’re both trying to bootstrap Logback. The ability to disable bootstrapping via the EmbeddedHiveMQBuilder would be great.
Hi @toellrich,
o.k., you should be fine with Artemis embedded.
But don’t forget the possibility to use either native or even embedded extensions. HiveMQ gives great opportunities …
Nevertheless I will do a test with Spring Boot next time.
If you are interested, I will tell you the results.