3 Replies Latest reply on Jan 31, 2013 3:24 PM by Paul Ferraro

    EJB Clustering in JBOSS as 7

    agas_4 Newbie

      I want to cluster EJB2.1 in Jboss 7. But the annotation @Clustered doesnt work for EJB2.1. So I have made a work around in which I use 2 xml files. 1) ejb-jar.xml (which is standard for EJB2.1) and 2) jboss-ejb3.xml (which is introduced in Jboss 7).

       

      1) ejb-jar.xml

       

      <?xml version="1.0" encoding="UTF-8"?>

      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"

                version="2.1">

                     <description>HelloWorld deployment descriptor</description>

                     <display-name>HelloWorld</display-name>

                     <enterprise-beans>

                                    <session>

                                                   <description> HelloWorld deployment descriptor</description>

                                                   <display-name>X</display-name>

                                                   <ejb-name>Y</ejb-name>

                                                   <home>com.ejb.HelloWorldHome</home>

                                                   <remote>com.ejb.HelloWorld</remote>

                                                   <ejb-class>com.ejb.HelloWorldBean</ejb-class>

                                                   <session-type>Stateless</session-type>

                                                   <transaction-type>Container</transaction-type>

                                    </session>

                     </enterprise-beans>

                     <assembly-descriptor>

                                    <container-transaction>

                                                   <method>

                                                                  <ejb-name>Y</ejb-name>

                                                                  <method-name>*</method-name>

                                                   </method>

                                                   <trans-attribute>Required</trans-attribute>

                                    </container-transaction>

                     </assembly-descriptor>

           </ejb-jar>

       

       

      2) jboss-ejb3.xml

       

       

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"

                        xmlns="http://java.sun.com/xml/ns/javaee"

                        xmlns:c="urn:clustering:1.0"

                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                        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">

                <assembly-descriptor>

                          <c:clustering>

                  <ejb-name>Y</ejb-name>

                  <c:clustered>true</c:clustered>

              </c:clustering>

                </assembly-descriptor>

      </jboss:ejb-jar>

       

       

      In the ejb-jar.xml i have defined an EJB named "Y" and in jboss-ejb3.xml i have made this EJB "Y" clustered.

       

      Using this the clustering for EJB2.1 is working fine.

       

      I want to know is this the correct way to implement clustering for EJB 2.1 in Jboss as 7?