Mark EJB's as clustered by using the jboss-ejb3.xml deployment descriptor seems to work not correct in any case

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 6.0.x
    • 6.1.x
  • 6.2.x
  • 6.3.x

Issue

If enterprise beans in an application are marked as clustered with the jboss-ejb3.xml deployment descriptor (DD)

<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee" xmlns="http://java.sun.com/xml/ns/javaee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="urn:security"
                  xmlns:c="urn:clustering:1.0" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd
                     http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
                  version="3.1" impl-version="2.0">
  <enterprise-beans>
  </enterprise-beans>
  <assembly-descriptor>
    <c:clustering>
      <ejb-name>Bean1</ejb-name>
      <ejb-name>Bean2</ejb-name>
      <ejb-name>Bean3</ejb-name>
      <c:clustered>true</c:clustered>
    </c:clustering>
  </assembly-descriptor>
</jboss:ejb-jar>

The bean seems to be clustered as the invocation from a client will be load balanced and the beans are invoked in different JBoss instances.

But if a ClusterNodeSelector will be registered at the client side with the remote.cluster..clusternode.selector the selector will only be invoked for the last registered bean (Bean3 in this example)

Resolution

From 6.4.0 onwards the wrong XML will be reported and the application is not deployed.

The correct configutation is as followed:
In most of the use-cases all beans should be clustered. This can be achieved by using a wildcard to mark all beans.

  <assembly-descriptor>
    <c:clustering>
      <ejb-name>*</ejb-name>
      <c:clustered>true</c:clustered>
    </c:clustering>
  </assembly-descriptor>

If only a subset of beans need to be clustered the configuration must repeat the clustering element as shown

  <assembly-descriptor>
    <c:clustering>
      <ejb-name>Bean1</ejb-name>
      <c:clustered>true</c:clustered>
    </c:clustering>
    <c:clustering>
      <ejb-name>Bean2</ejb-name>
      <c:clustered>true</c:clustered>
    </c:clustering>
  </assembly-descriptor>

Root Cause

This is a configuration/parsing problem. From the XML schema it is only possible to have one element.
There is a Content from issues.jboss.org is not included.WFLY-2011 and an This content is not included.EAP BZ1004856 report that the application should not being deployed.

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.