3 Replies Latest reply on Jun 14, 2011 3:26 AM by Ron K

    HA-Singleton problem

    Ron K Newbie

      Hi all,

       

      I tried to set up a HA-Singletonw ith the here described concept: http://docs.jboss.org/jbosscache/2.2.1.GA/pojo/userguide_en/html/ch05s06s03.html in JBoss AS 6.

       

      Whenever I try to deploy the bean through the farm service, I get the following error: 

       

      DEPLOYMENTS IN ERROR:

        Deployment "SBHASingletonController" is in error due to the following reason(s): java.lang.RuntimeException: unable to determine member type for annotation: org.jboss.aop.microcontainer.aspects.jmx

      JMX.value

        Deployment "StarterBean" is in error due to the following reason(s): java.lang.RuntimeException: unable to determine member type for annotation: org.jboss.aop.microcontainer.aspects.jmx.JMX.value

       

      My jboss-beans.xml:

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

      <deployment xmlns="urn:jboss:bean-deployer:2.0">

        <!-- This bean is an example of a clustered singleton -->

        <bean name="StarterBean" class="failover.StarterBean">

          <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(...)</annotation>

        </bean>

       

        <bean name="SBHASingletonController" class="org.jboss.ha.singleton.HASingletonController">

          <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(...)</annotation>

          <property name="HAPartition"><inject bean="HAPartition"/></property>

          <property name="target"><inject bean="StarterBean"/></property>

          <property name="targetStartMethod">startSingleton</property>

          <property name="targetStopMethod">stopSingleton</property>

        </bean>

      </deployment>

       

      My Singleton:

       

       

      @Singleton

      @Clustered

      //@Startup

      // @Stateless

      // @Singleton

      @CacheConfig(name="sfsb/dist")

      public class StarterBean implements Starter {

       

          // @EJB(lookup="FailoverBean/remote")

          // private Failover b;

          private Failover b;

          private InitialContext ctx;

          private boolean isMasterNode = false;

       

          public StarterBean() throws NamingException {

              // count();

              ctx = new InitialContext();

              b = (Failover) ctx.lookup("FailoverBean/remote");

              System.out.println("TEST");

              System.out.println("STARTERBEAN: " + b);

          }

       

          public boolean isMasterNode() {

              return isMasterNode;

          }

       

          public void startSingleton() {

              isMasterNode = true;

              count();

          }

       

          public void stopSingleton() {

              isMasterNode = false;

          }

         

          public void count() {

              b.printCount(5000);

          }

      }

        • 1. Re: HA-Singleton problem
          Ron K Newbie

          Is my question that stupid or does really nobody has a clue of what im doing wrong?

          In one of the previous versions i saw some kind of problems listed as a bug, but couldnt find if its resolved...

           

          I'd really appreciate if somebody could take a look at my post,

           

          thanks,

          • 2. Re: HA-Singleton problem
            Werner Johansson Newbie

            Been looking at this my self a few times but general trick seems to be get the class into a service first which is done by either making it a mbean, after that your xml will run it fairly well.

             

            @Service( objectName="<SomeName>Service" )

             

            Should kick it up to a service to be used by the JBoss in 6 Final at least. Tried and tested.

            To make it a HA-Singleton is a bit of a work but essentially this is how you do it.

            Your create() method in the service looks it self up, saves the reference and unbinds it. The startSingleton function you define in your xml then binds it back into the JNDI tree and runs as it should. Your stopSingleton of course unbinds it as well in preparation for someone else to become the masterNode.

            There are a number of guides floating around on the forums. If you look at the one thread I have on these forums you'll get a link to how it was done in JBoss 5. Right now you just need the <somename>-service.xml which looks like this:

             

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

            <server>

                <mbean name="se.ports:service=EchoService-Controller"

                       code="org.jboss.ha.singleton.HASingletonController">

                    <depends>ports:service=EchoService</depends>

                    <attribute name="HAPartition"><inject bean="HAPartition" /></attribute>

                    <attribute name="TargetName">ports:service=EchoService</attribute>

                    <attribute name="TargetStartMethod">startSingleton</attribute>

                    <attribute name="TargetStopMethod">stopSingleton</attribute>

                 </mbean>

            </server>

             

            It supposed to into a folder called META-INF to be picked up properly by the JBoss.

            You also need the remote interface as well as the MBean interface set up so that the JBoss can pick it up properly.

            The JBoss 6 clustering pdf

            But I'm not very good at this stuff so I can only speak from my own failures and successes.

            http://community.jboss.org/wiki/WritingAClusteredHASingletonService is a fairly good guide. I refer to his unbind code

            above. Hope it helps a little at least.

            http://docs.jboss.org/jbossas/clustering/JBossClustering6.pdf - hard to find sadly but has a good example as well.

            • 3. Re: HA-Singleton problem
              Ron K Newbie

              Had it in my implementation as well, but it either didnt work...same error.

              I decided to change my structure to avoid using a singleton, but thanks for your answer.