-
Bug
-
Resolution: Done
-
Major
-
32.0.0.Final
-
None
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:
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.
- links to