WildFly 31+ crashes during startup when live-only HA policy is configured in messaging

125 views
Skip to first unread message
Assigned to ehug...@redhat.com by me

Bernd Köcke

unread,
Apr 24, 2024, 9:10:36 AM4/24/24
to WildFly
Hello,
WildFly 31.0.1.Final and 32.0.0.Beta1 are throwing a ClassCastExceptin during startup when I configure the live-only HA policy in messaging-activemq subsystem. The exception is:

15:40:08,854 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 94) MSC000001: Failed to start service org.wildfly.messaging.activemq.server.default.jms.manager: org.jboss.msc.service.StartException in service org.wildfly.messaging.activemq.server.default.jms.manager: java.lang.ClassCastException: class org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration cannot be cast to class org.apache.activemq.artemis.core.config.ha.PrimaryOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration and org.apache.activemq.artemis.core.config.ha.PrimaryOnlyPolicyConfiguration are in unnamed module of loader 'org.apache.ac...@2.32.0' @7dcc9a0d)
        at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.doStart(JMSService.java:198)
        at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService$1.run(JMSService.java:84)
        [...]
Caused by: java.lang.ClassCastException: class org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration cannot be cast to class org.apache.activemq.artemis.core.config.ha.PrimaryOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration and org.apache.activemq.artemis.core.config.ha.PrimaryOnlyPolicyConfiguration are in unnamed module of loader 'org.apache.ac...@2.32.0' @7dcc9a0d)
        at org.apache.ac...@2.32.0//org.apache.activemq.artemis.core.config.ConfigurationUtils.getHAPolicy(ConfigurationUtils.java:75)
        at org.apache.ac...@2.32.0//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:685)
        at org.apache.ac...@2.32.0//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:617)
        at org.apache.ac...@2.32.0//org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl.start(JMSServerManagerImpl.java:374)
        at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.doStart(JMSService.java:194)

The root cause comes from Artemis. But it is triggered because WildFly uses a meanwhile deprecated class. Even if Artemis fixes it, the class causing the exception will go away in a while. Would it be possible to add a the PrimaryOnly HA policy to the WildFly messaging subsystem configuration?

Detailed description:

In Artemis 2.32.0 and newer a new class PrimaryOnlyPolicyConfiguration appeared. It seems that it should replace the LiveOnlyPolicyConfiguration (annotaed with @Deprecated(forRemoval = true)). Both classes have a getType method and the one in LiveOnlyPolicyConfiguration returns the enum for PrimaryOnlyPolicyConfiguration. And there is a helper class "ConfigurationUtils" with a "getHAPolicy" method with the following code:

if (conf == null) {
    return new PrimaryOnlyPolicy();
}

switch (conf.getType()) {
   case PRIMARY_ONLY: {
      PrimaryOnlyPolicyConfiguration pc = (PrimaryOnlyPolicyConfiguration) conf;
      return new PrimaryOnlyPolicy(getScaleDownPolicy(pc.getScaleDownConfiguration()));
   }
   case REPLICATED: {
   ...

As you can see, if a LiveOnlyPolicyConfiguration is given, it returns the enum for PrimaryOnlyPolicyConfiguration and then it is casted to PrimaryOnly. This can't work and it is the line where the exception is thrown.

You don't see an exception with the provided config files, because in these files the policy is not configured and then the first lines of the method are executed which return a newly created PrimaryOnlyPolicy object.

I configured live-only because I wanted to be sure that scale down is active. I will now check if the defaults of PrimaryOnly are doing the same.

I will also try to talk to the Artemis user list, because I think this is a bug in Artemis. But as mentioned above, I think it would be a good idea for WildFly to use PrimaryOnly instead of LiveOnly in future.

Kind regards
Bernd

Bernd Köcke

unread,
Apr 30, 2024, 3:21:57 AM4/30/24
to WildFly
Hello all,

I use WildFly in Kubernetes and when I reduce the number of instances, I need a method to move all messages from the leaving node to the others. For this I used Live-Only with Scale-Down in the messaging subsystem. As mentioned above, with this configuration WildFly 31+ crashes during startup. Do you have any ideas how I can get the same behavior with the default HA policy settings? Because when I omit the Live-Only configuration, no scale down happens.

Thanks in advance. Kind regards
Bernd

Emmanuel Hugonnet

unread,
May 2, 2024, 10:38:59 AM5/2/24
to Bernd Köcke, WildFly
I've open https://issues.redhat.com/browse/WFLY-19305 and I think we should update WildFly to use the 'new' class.
JFYI: on K8s it is considered a better practice to have a proper Artemis cluster (but that doesn't mean we shouldn't fix this ;) )

Emmanuel
> --
> You received this message because you are subscribed to the Google Groups "WildFly" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wildfly/14ae6c6a-d22a-437c-b165-552e50c99695n%40googlegroups.com
> <https://groups.google.com/d/msgid/wildfly/14ae6c6a-d22a-437c-b165-552e50c99695n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Bernd Köcke

unread,
May 2, 2024, 10:59:22 AM5/2/24
to WildFly
Hello Emmanuel,
thanks a lot. A fix would be great.

And yes, I have also a setup with a remote Artemis cluster. But to migrate from on premise to the cloud, it is really easy to have a stateful set with some persistent volumes. But then I have to make sure, that while scaling up and down, no messages are lost. That's why I tried the embedded setup and need some possibility to save the messages when a pod goes away.

Thanks again,
Bernd

Emmanuel Hugonnet

unread,
May 3, 2024, 3:39:17 AM5/3/24
to Bernd Köcke, WildFly
JFYI Apache Artemis team has also an entry: https://issues.apache.org/jira/browse/ARTEMIS-4759
Emmanuel
> <https://groups.google.com/d/msgid/wildfly/14ae6c6a-d22a-437c-b165-552e50c99695n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google Groups "WildFly" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wildfly/d0a886e6-1bb4-4d4c-bb27-cb9d594db456n%40googlegroups.com
> <https://groups.google.com/d/msgid/wildfly/d0a886e6-1bb4-4d4c-bb27-cb9d594db456n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Bernd Köcke

unread,
May 3, 2024, 4:18:35 AM5/3/24
to WildFly
Yes, I saw the Email this morning. I posted a note to their list, because the CCE came from their code. But because the deprecation annotation says that live only will go away, I thought it would be a good idea to switch to "primary only" in WildFly, too. But I don't have a clue how long it will stay deprecated and when this option is finally removed from Artemis.

Emmanuel Hugonnet

unread,
May 28, 2024, 4:48:56 AM5/28/24
to wil...@googlegroups.com
This should be fixed in WildFly 32.0.1
Emmanuel
> <https://groups.google.com/d/msgid/wildfly/d0a886e6-1bb4-4d4c-bb27-cb9d594db456n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google Groups "WildFly" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wildfly/4390fafb-26e1-4e50-a3e2-09938aa1cd5cn%40googlegroups.com
> <https://groups.google.com/d/msgid/wildfly/4390fafb-26e1-4e50-a3e2-09938aa1cd5cn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Bernd Köcke

unread,
May 29, 2024, 3:10:08 AM5/29/24
to WildFly
I will give it a try, when it is out. Thanks a lot!

Bernd Köcke

unread,
Jun 4, 2024, 6:31:21 AM6/4/24
to WildFly
Hello Emmanuel,
I tried WildFly 32.0.1.Final and it worked very well. Thank you very much for your support.
Kind regards
Bernd
Reply all
Reply to author
Forward
0 new messages