6 Replies Latest reply on Nov 12, 2004 7:49 AM by Cedric Jehasse

    RMIAdapter and singleton in jboss 4.0.0

    Cedric Jehasse Newbie

      I'm trying to acces a mbean remotely in JBoss 4.0.0. I followed this topic:
      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=55794
      but at step 3.1 jboss 4.0.0 doesnt seem to have the file jmx-invoker-adaptor-server.sar
      so i can't deploy the rmiadaptor as a singleton.
      Another thing i found is
      http://www.jboss.org/wiki/Wiki.jsp?page=JBossHASingletonRemoteAccess
      is this a way to do that, because i tried it, and that doesnt seem to work either.
      Anyone got an idea how this can be done in jboss 4.0.0?
      tia

        • 1. Re: JBoss Clustering Rocks! But How do I get the Partition N
          Cedric Jehasse Newbie

          Well. I re-read the Clustering docs and although it didn't give me the answer to my question directly, it did give me some things to think about which led to a solution. I don't know that it's THEE solution but it seems to work OK.

          For anyone else whos wondering here's how I am getting the partition name. I basically lookup the HASingletonDeployer web service and ask it what the value is of the "PartitionName" attribute for the service.

          I think this is returning me the partition that that particular service is aware of. I don't think this will work should I decide to create SubPartitions within the same JBoss instance. But for now since I am only using 1 partition name per jboss instance I think that it will work ok...

          The code is below for those that are curious:

          The jar to have in your classpath is:
          JBOSS_HOME/lib/jboss-jmx.jar

          ...

          import javax.management.MBeanServer;
          import javax.management.MBeanServerFactory;
          import javax.management.ObjectName;

          ...

          private String clusterPartitionName = null;
          private ObjectName serviceName = null;
          private MBeanServer localServer = null;

          localServer = (MBeanServer)
          MBeanServerFactory.findMBeanServer(null).iterator().nex();

          serviceName =
          new ObjectName("jboss.ha:service=HASingletonDeployer");

          try
          {
          clusterPartitionName =
          localServer.getAttribute(serviceName, "PartitionName").toString();
          }
          catch(Exception e)
          {
          System.out.println("an Exception Occured getting the PartitionName");
          e.printStackTrace();
          }


          ...

          Hope this helps someone.

          • 2. Re: RMIAdapter and singleton in jboss 4.0.0
            derek akers Newbie

            I am wondering if you got this going. I am in a similar situation. Looking for a way to lookup/invoke on a HASingleton MBean in a cluster. Currently can't get a handle to it using the stardard methods.

            • 3. Re: RMIAdapter and singleton in jboss 4.0.0
              Cedric Jehasse Newbie

              I've got it going now. Just did like it's explained in:
              http://www.jboss.org/wiki/Wiki.jsp?page=JBossHASingletonRemoteAccess

              I didn't set the properties like it's needed for the HA-JNDI lookup, that's what went wrong with me.

              • 4. Re: RMIAdapter and singleton in jboss 4.0.0
                derek akers Newbie

                Weird man. I swear I am doing the same thing. I know that there are n posts on heree about how to do this, and they all suggest sort of the same thing. I have been looking into this for a while now and I can't seem to get it. I have the following in my jmx-invoker-service.xml (4.0.0):

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

                <!-- $Id: jmx-invoker-service.xml,v 1.2 2004/11/22 23:54:46 muhr Exp $ -->


                <!-- The JRMP invoker proxy configuration for the InvokerAdaptorService -->

                <!-- Use the standard JRMPInvoker from conf/jboss-service.xxml -->
                <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmp
                <!-- The target MBean is the InvokerAdaptorService configured below -->
                <depends optional-attribute-name="TargetName">jboss.jmx:type=adaptor,name=Invoker
                <!-- Where to bind the RMIAdaptor proxy -->
                jmx/invoker/RMIAdaptor
                <!-- The RMI compabitle MBeanServer interface -->
                org.jboss.jmx.adaptor.rmi.RMIAdaptor,
                org.jboss.jmx.adaptor.rmi.RMIAdaptorExt



                org.jboss.proxy.ClientMethodInterceptor
                org.jboss.proxy.SecurityInterceptor
                org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor
                org.jboss.invocation.InvokerInterceptor




                <!-- ANOTHER ONE FOR SINGLETONS -->

                <!-- Use the standard JRMPInvoker from conf/jboss-service.xxml -->
                <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmp
                <!-- The target MBean is the InvokerAdaptorService configured below -->
                <depends optional-attribute-name="TargetName">jboss.jmx:type=adaptor,name=Invoker
                <!-- Where to bind the RMIAdaptor proxy -->
                jmx/invoker/SingletonRMIAdaptor
                <!-- The RMI compabitle MBeanServer interface -->
                org.jboss.jmx.adaptor.rmi.RMIAdaptor, org.jboss.jmx.adaptor.rmi.RMIAdaptorExt



                org.jboss.proxy.ClientMethodInterceptor
                org.jboss.proxy.SecurityInterceptor
                org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor
                org.jboss.invocation.InvokerInterceptor





                <!-- Create a mapping from the legacy jmx-rmi-adaptor.sar binding to the
                jmx-invoker-adaptor-server.sar JndiName specified above for backwards
                portability.


                jmx/rmi/RMIAdaptor
                jmx/invoker/RMIAdaptor

                -->
                <!-- This is the service that handles the RMIAdaptor invocations by routing
                them to the MBeanServer the service is deployed under. -->
                <mbean code="org.jboss.jmx.connector.invoker.InvokerAdaptorService"
                name="jboss.jmx:type=adaptor,name=Invoker"
                xmbean-dd="">

                The JMX Detached Invoker Service
                org.jboss.jmx.connector.invoker.InvokerAdaptorService

                <!-- Attributes -->

                The class name of the MBean
                Name
                java.lang.String


                The status of the MBean
                State
                int


                The status of the MBean in text form
                StateString
                java.lang.String


                The interfaces the invoker proxy supports
                ExportedInterfaces
                [Ljava.lang.Class;


                Map(Long hash, Method) of the proxy interface methods
                MethodMap
                java.util.Map

                <!-- Operations -->

                The start lifecycle operation
                start


                The stop lifecycle operation
                stop


                The detyped lifecycle operation (for internal use only)
                jbossInternalLifecycle

                The lifecycle operation
                method
                java.lang.String

                <return-type>void</return-type>



                The detached invoker entry point
                invoke

                The method invocation context
                invocation
                org.jboss.invocation.Invocation

                <return-type>java.lang.Object</return-type>
                <!-- Uncomment to require authenticated users





                -->


                org.jboss.jmx.adaptor.rmi.RMIAdaptor,
                org.jboss.jmx.adaptor.rmi.RMIAdaptorExt



                <!-- MORE DUPLICATES FOR SINGLETONS -->
                <mbean code="org.jboss.jmx.connector.invoker.InvokerAdaptorService"
                name="jboss.jmx:type=adaptor,name=SingletonInvoker"
                xmbean-dd="">

                The JMX Detached Invoker Service
                org.jboss.jmx.connector.invoker.InvokerAdaptorService

                <!-- Attributes -->

                The class name of the MBean
                Name
                java.lang.String


                The status of the MBean
                State
                int


                The status of the MBean in text form
                StateString
                java.lang.String


                The interfaces the invoker proxy supports
                ExportedInterfaces
                [Ljava.lang.Class;


                Map(Long hash, Method) of the proxy interface methods
                MethodMap
                java.util.Map

                <!-- Operations -->

                The start lifecycle operation
                start


                The stop lifecycle operation
                stop


                The detyped lifecycle operation (for internal use only)
                jbossInternalLifecycle

                The lifecycle operation
                method
                java.lang.String

                <return-type>void</return-type>



                The detached invoker entry point
                invoke

                The method invocation context
                invocation
                org.jboss.invocation.Invocation

                <return-type>java.lang.Object</return-type>
                <!-- Uncomment to require authenticated users





                -->



                org.jboss.jmx.adaptor.rmi.RMIAdaptor,
                org.jboss.jmx.adaptor.rmi.RMIAdaptorExt




                jboss:service=DefaultPartition
                jboss.jmx:type=adaptor,name=SingletonInvoker
                jboss.jmx:type=adaptor,name=SingletonInvoker
                start
                stop





                Some suggest replacing the original configuration there, however doing this makes the web-console die a horrible death on startup, so I merely added in the deployment for my MBean. I have commented out the NamingAlias tags as has been suggested elsewhere... seems to make no difference though. Seems to me unreasonable that web-console and a HASingleton would not be allowed to run at the same time. My current Servlet lookup code is as follows:

                log.info("Attempting MBean lookup");
                props = new Properties();
                props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                InitialContext ctx = new InitialContext(props);

                Object obj = ctx.lookup("jmx/invoker/SingletonRMIAdaptor");
                if (!(obj instanceof RMIAdaptor))
                {
                throw new ClassCastException("Object not of type: RMIAdaptorImpl, but: " + (obj == null ? "not found" : obj.getClass().getName()));
                }
                RMIAdaptor rmiAdaptor = (RMIAdaptor)obj;
                log.info("DataManagerMBean deployed somewhere? "+rmiAdaptor.isRegistered(new ObjectName("ipdevco.common.mbean:service=DataManager")));

                I have tried variants as well, using MBeanServer.

                Every time the servlet runs from the box running the master server, the last log statement indicates that the MBean is deployed and accessible. However from every other machine in the cluster this check fails. I have left the Provider URL out of the Properties in this example, though it seems to make no differenct whether I specify localhost:1100, "", :1100, or a static string of IPs representing each of the machines in the cluster (running in the default partition). I simply cannot get acess to this MBean when it runs on another server in the cluster.

                Now, the servers are running instances of the same app .ear in the all/deploy directory, and the SAR containing the MBean is in the deploy-hasingleton dir. For measure, the entries in the SAR jboss-service.xml are:



                <!-- HASingletonController to make DataManagerMBean run as a HASingleton -->

                ipdevco.common.mbean:service=DataManager
                start
                stop
                true
                jboss:service=DefaultPartition
                ipdevco.common.mbean:service=DataManager


                I thought maybe there was a way to get a handle to each machine in the cluster and force the thing to manually cycle through them and .... well, just seems like that's too much, esp. since some of y'all have got this kicking.

                I realize this to be something that should be relatively straightforward, and undoubtedly the intention of the JBoss dev group was to make it so. I conclude that I must have completely missed something, somewhere. Anyone know what it is?

                • 5. Re: RMIAdapter and singleton in jboss 4.0.0
                  derek akers Newbie

                  awesome, no tag filter here. Hopefully the un-XML up there makes sense.

                  • 6. Re: RMIAdapter and singleton in jboss 4.0.0
                    derek akers Newbie

                    The markup is in the source if you view it.