14 Replies Latest reply on Dec 5, 2006 11:22 PM by brian.stansberry

    same SLSB in multiple clusters

    ablevine1

      If I have an EJB3 SLSB and I want it to be in multiple clusters, how do I achieve this. The @Clustered annotation seems to tie it to only one cluster, as the partition name parameter refers to only one partition. Is there some way I can deploy the same Session Bean in two clusters??

        • 1. Re: same SLSB in multiple clusters
          ablevine1

          So, I,ve found that this is supposed to be able to be done by using jboss.xml files in the META-INF directory of your ejb jar file, but I can;t seem to get it to work

          My session implemetation class looks like this:
          @Stateless
          @Remote(ProductManagerSession.class)
          @Local(ProductManagerSession.class)
          public class ProductManagerSessionImpl extends AbstractManagerSession implements ProductManagerSession
          {
          ....
          }

          with both a remote and local interface:
          then my jboss.xml file looks like this for one of the clusters:


          <enterprise-beans>
          <!-- ProductManagerSessionImpl remote -->

          <ejb-name>ProductManagerSessionImpl</ejb-name>
          <jndi-name>ProductManagerSessionImpl/remote</jndi-name>
          true
          <cluster-config>
          <partition-name>AppPartition</partition-name>
          <load-balance-policy>org.jboss.ha.framework.interfaces.FirstAvailable</load-balance-policy>
          </cluster-config>

          <!-- ProductManagerSessionImpl local -->

          <ejb-name>ProductManagerSessionImpl</ejb-name>
          <jndi-name>ProductManagerSessionImpl/local</jndi-name>
          true
          <cluster-config>
          <partition-name>AppPartition</partition-name>
          <load-balance-policy>org.jboss.ha.framework.interfaces.FirstAvailable</load-balance-policy>
          </cluster-config>

          </enterprise-beans>


          It is then packaged in an ear file named app.ear
          when I try to connect using a remote client using the jndi name app/ProductManagerSessionImpl/remote
          I get a NamingException saying "remote not bound"

          What am I doing wrong??
          Do I also need an ejb-jar.xml file??

          Is there something I am missing from jboss.xml??

          Any suggestions would be appreciated

          • 2. Re: same SLSB in multiple clusters
            ablevine1

            So, I,ve found that this is supposed to be able to be done by using jboss.xml files in the META-INF directory of your ejb jar file, but I can;t seem to get it to work

            My session implemetation class looks like this:
            @Stateless
            @Remote(ProductManagerSession.class)
            @Local(ProductManagerSession.class)
            public class ProductManagerSessionImpl extends AbstractManagerSession implements ProductManagerSession
            {
            ....
            }

            with both a remote and local interface:
            then my jboss.xml file looks like this for one of the clusters:


            <enterprise-beans>
            <!-- ProductManagerSessionImpl remote -->

            <ejb-name>ProductManagerSessionImpl</ejb-name>
            <jndi-name>ProductManagerSessionImpl/remote</jndi-name>
            true
            <cluster-config>
            <partition-name>AppPartition</partition-name>
            <load-balance-policy>org.jboss.ha.framework.interfaces.FirstAvailable</load-balance-policy>
            </cluster-config>

            <!-- ProductManagerSessionImpl local -->

            <ejb-name>ProductManagerSessionImpl</ejb-name>
            <jndi-name>ProductManagerSessionImpl/local</jndi-name>
            true
            <cluster-config>
            <partition-name>AppPartition</partition-name>
            <load-balance-policy>org.jboss.ha.framework.interfaces.FirstAvailable</load-balance-policy>
            </cluster-config>

            </enterprise-beans>


            It is then packaged in an ear file named app.ear
            when I try to connect using a remote client using the jndi name app/ProductManagerSessionImpl/remote
            I get a NamingException saying "remote not bound"

            What am I doing wrong??
            Do I also need an ejb-jar.xml file??

            Is there something I am missing from jboss.xml??

            Any suggestions would be appreciated

            • 3. Re: same SLSB in multiple clusters
              ablevine1

              REPOSTED DUE TO JUMBLED XML

              So, I,ve found that this is supposed to be able to be done by using jboss.xml files in the META-INF directory of your ejb jar file, but I can;t seem to get it to work

              My session implemetation class looks like this:
              @Stateless
              @Remote(ProductManagerSession.class)
              @Local(ProductManagerSession.class)
              public class ProductManagerSessionImpl extends AbstractManagerSession implements ProductManagerSession
              {
              ....
              }

              with both a remote and local interface:
              then my jboss.xml file looks like this for one of the clusters:

              <jboss>
               <enterprise-beans>
               <!-- ProductManagerSessionImpl remote -->
               <session>
               <ejb-name>ProductManagerSessionImpl</ejb-name>
               <jndi-name>ProductManagerSessionImpl/remote</jndi-name>
               <clustered>true</clustered>
               <cluster-config>
               <partition-name>AppPartition</partition-name>
               <load-balance-policy>org.jboss.ha.framework.interfaces.FirstAvailable</load-balance-policy>
               </cluster-config>
               </session>
               <!-- ProductManagerSessionImpl local -->
               <session>
               <ejb-name>ProductManagerSessionImpl</ejb-name>
               <jndi-name>ProductManagerSessionImpl/local</jndi-name>
               <clustered>true</clustered>
               <cluster-config>
               <partition-name>AppPartition</partition-name>
               <load-balance-policy>org.jboss.ha.framework.interfaces.FirstAvailable</load-balance-policy>
               </cluster-config>
               </session>
               </enterprise-beans>
              </jboss>
              

              It is then packaged in an ear file named app.ear
              when I try to connect using a remote client using the jndi name app/ProductManagerSessionImpl/remote
              I get a NamingException saying "remote not bound"

              What am I doing wrong??
              Do I also need an ejb-jar.xml file??

              Is there something I am missing from jboss.xml??

              Any suggestions would be appreciated

              • 4. Re: same SLSB in multiple clusters
                ablevine1

                additionally, I would like to add that I am using JBoss-4.0.4GA with the EJB3.0 release that came bundled with it

                • 5. Re: same SLSB in multiple clusters
                  ablevine1

                  I figured out the correct way to do this file after quite a bit of trial and error:

                  <jboss>
                   <enterprise-beans>
                   <!-- ProductManagerSessionImpl just one entry for each session bean and leave out the jndi names-->
                   <session>
                   <ejb-name>ProductManagerSessionImpl</ejb-name>
                   <clustered>true</clustered>
                   <cluster-config>
                  <!-- use notation below instead of actual partition name -->
                   <partition-name>${jboss.partition.name}</partition-name>
                   <load-balance-policy>org.jboss.ha.framework.interfaces.FirstAvailable</load-balance-policy>
                   </cluster-config>
                   </session>
                   </enterprise-beans>
                  </jboss>
                  


                  However now when one of the servers in the partition I get a CannotConnectException until I create a new context and do a new lookup.

                  • 6. Re: same SLSB in multiple clusters
                    ablevine1

                    I meant to say that when one of the servers in the partition is brought down I get a CannotConnectException from the client, so it seems as if the automatic failover in the client stub is not working. could changing the load balancing policy fix this??

                    • 7. Re: same SLSB in multiple clusters
                      jotis99

                      I'm facing the same issue? Can you post the sample XMl snippset for ProductManagerSessionImpl in the the ejb-jar.xml?

                      • 8. Re: same SLSB in multiple clusters
                        jotis99

                        Shouldn't JBoss @Clustered.partiotion automatically pick up the partition name specified in ${jboss.partition.name}? Why is it hard-coded to read DefaultPartition? Developers shouldn't need to add this to jboss.xml. Is this is a bug?

                        • 9. Re: same SLSB in multiple clusters
                          brian.stansberry

                          This is a missing bit of functionality. See http://jira.jboss.com/jira/browse/EJBTHREE-424.

                          • 10. Re: same SLSB in multiple clusters
                            jotis99

                            I'm trying to add a Clustered partition name in the jboss.xml since I cannot hardcode it as an annotation (EJB deploeyed in 2 clusters). I've tried numerous combinations and scoured the forums to no avail. Does JBoss support jboss-specific overrides in jboss.xml? THe following did NOT work for me. Is this a JBoss bug or my bug? Do I need an entry ejb-jar.xml at all if I'm only adding stuff in jboss.xml?

                            NOTE: this web app is garbling my HTML post for the clustered element!

                            ------------
                            jboss.xml

                            <enterprise-beans>

                            <ejb-name>ClusteredSampleImpl</ejb-name>
                            &lt;clustered&gt;true &lt;/clustered&gt;
                            <cluster-config>
                            <partition-name>ApplicationPartition</partition-name>
                            &lt;load-balance-policy>org.jboss.ha.framework.interfaces.RandomRobin&lt;/load-balance-policy>
                            </cluster-config>

                            </enterprise-beans>


                            -------------------
                            <enterprise-beans>

                            <ejb-name>ClusteredSampleImpl</ejb-name>

                            </enterprise-beans>

                            ----------------------
                            where the I have:

                            @Local
                            @Remote
                            public interface ClusteredSample
                            {
                            public String ping() ;
                            public String getSystemProperty(String propertyName) ;
                            }


                            @Stateless
                            public class ClusteredSampleImpl implements ClusteredSample
                            {
                            }


                            • 11. Re: same SLSB in multiple clusters
                              jotis99

                              Does this (JIRA EJBTHREE-424) mean that you cannot specify a partition name from jboss.xml too? I've tried lots of permutations to no avail.

                              The following from jboss.xml doesn't seem to work:
                              <cluster-config>
                              <partition-name>ApplicationPartition</partition-name>
                              <load-balance-policy>org.jboss.ha.framework.interfaces.RandomRobin</load-balance-policy>
                              </cluster-config>

                              • 12. Re: same SLSB in multiple clusters
                                jotis99

                                Does this (JIRA EJBTHREE-424) mean that you cannot specify a partition name from jboss.xml too? I've tried lots of permutations to no avail.

                                The following from jboss.xml doesn't seem to work:
                                <cluster-config>
                                <partition-name>ApplicationPartition</partition-name>
                                <load-balance-policy>org.jboss.ha.framework.interfaces.RandomRobin</load-balance-policy>
                                </cluster-config>

                                • 13. Re: same SLSB in multiple clusters
                                  ablevine1

                                  apparently not unless you are using EJB3 RC9 or higher

                                  • 14. Re: same SLSB in multiple clusters
                                    brian.stansberry