Hi all,
for my current project I try to incorporate EmbeddedHiveMQ into an existing OSGi environment (based on Equinox).
So far, I created my Service-Component as proposed by the Github README:
public void activate() {
final EmbeddedHiveMQBuilder embeddedHiveMQBuilder = EmbeddedHiveMQ.builder();
...
try (final EmbeddedHiveMQ hiveMQ = embeddedHiveMQBuilder.build()) {
hiveMQ.start().join();
...
} catch (final Exception ex) {
ex.printStackTrace();
}
}
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?
Best regards,
janosch