10 Replies Latest reply on Oct 22, 2004 11:09 AM by James Adams

    How to access HASingleton MBeans from a non-master cluster n

    James Adams Novice

      I have an application which uses several HA Singleton MBeans. It is working well when running as a single node cluster. But when I run it on additional nodes I can't locate the singleton MBeans. It seems that the singleton MBeans are only registered with the MBeanServer on the initial node, and so the components which run on other nodes can't find a MBeanServer which has the singleton Mbeans registered, and hence can't access the required singleton MBean operations. Without these my application is hosed and can't run in a cluster.

      Below is example code which is accessing one of my singleton MBeans. It works fine in Servlets and EJBs running on the first node, but not at all on any other nodes.

       // get a list of MBeanServers
       ArrayList mbeanServers = MBeanServerFactory.findMBeanServer(null);
      
       // find the correct MBeanServer to use for accessing the singleton MBean
       MBeanServer mbeanServer = null;
       for (int i = 0; i < mbeanServers.size(); i++)
       {
       // see if this MBeanServer has the MBean registered
       if (((MBeanServer) mbeanServers.get(i)).isRegistered(new ObjectName("grover.mbean:service=AllUserInfo")))
       {
       // make this the MBeanServer
       mbeanServer = (MBeanServer) mbeanServers.get(i);
      
       // break out of the loop
       break;
       }
       }
      
       if (mbeanServer != null)
       {
       // find out if the user is already in te table or not
       Boolean userInTable = (Boolean) mbeanServer.invoke(new ObjectName("grover.mbean:service=AllUserInfo"),
       "isUserInTable",
       new Object[]{loginId},
       new String[]{"java.lang.String"});
      
       // if the user is in the table already then get their info
       if (userInTable.booleanValue())
       {
       // get the pre-existing user's information
       userInfo = (UserInfo) mbeanServer.invoke(new ObjectName("grover.mbean:service=AllUserInfo"),
       "getUserInfo",
       new Object[]{loginId},
       new String[]{"java.lang.String"});
       }
       else
       {
       // create and populate a new user information object
       userInfo = new UserInfo();
       userInfo.setLoginTime(Calendar.getInstance());
       userInfo.setUserId(loginId);
       userInfo.setUserType(0); // 0 = HIM, 1 = WEB
      
       // add this user's info to the table
       mbeanServer.invoke(new ObjectName("grover.mbean:service=AllUserInfo"),
       "addUserInfo",
       new Object[]{userInfo},
       new String[]{"com.hsp.grover.util.UserInfo"});
       }
       }
       else
       {
       // log the error
       m_logger.error("Unable to find an MBeanServer with a registered AllUserInfo singleton MBean");
      
       // throw an exception
       throw new ServletException("Unable to find an MBeanServer with a registered AllUserInfo singleton MBean");
       }
      



      I put in the search for an MBeanServer where the MBean is registered but it doesn't seem to do any good since the only MBeanServer found is the one available locally and not the total number of MBeanServers available on the cluster, which is what I was after.

      How then does one go about this ? Should I do some sort of JNDI registration in the singleton MBeans' startSingleton() methods and lookup the MBeans with JNDI instead of using the MBeanServer.invoke() method of accessing the MBeans' operations ?

      Thanks in advance for any help.


      --James

        • 1. Re: How to access HASingleton MBeans from a non-master clust
          James Adams Novice

          I have just discovered a section in the JMX book (Lindfors, et al) about an RMI Connector implementation which looks promising. Is this the solution I should be pursuing ? Any good online references on this topic ?


          --James

          • 2. Re: How to access HASingleton MBeans from a non-master clust
            Scott Stark Master

            Yes, you have to use a jmx remote connector. The book you mention is hopelessly out of date. Use the online admin/devel guide.

            http://www.jboss.org/docs/index

            • 3. Re: How to access HASingleton MBeans from a non-master clust
              James Adams Novice

              I can't find any reference to a JMX Remote Connector anywhere in the Admin/Devel 3.2.3 Guide, which I assume is the latest Admin/Devel Guide available. Are you referring to using the InvokerAdaptorService (p. 179) in the same manner as the RMIAdaptor (p. 90) being used in the RMIAdaptor client example (p. 94) ?

              Assuming that this is the case I have several questions.

              In the RMIAdaptor client example it gets the RMIAdaptor like so:

              RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");
              


              I assume that in a clustered deployment each node will make available a RMIAdaptor (like a MBeanServer) which provides access to its registered MBeans. So only one node in a cluster will be able to provide a RMIAdaptor with access to my HASingleton MBeans, since these are only registered on the master node of the cluster. Is this true, or will a RMIAdaptor only be available from the master node ? If there is one per node then how can you know that the RMIAdaptor that is found from the lookup is the one which allows access to the singleton MBeans registered on the master node ? It's not clear that the lookup will find the correct RMIAdaptor (which must come from the master node) with the MBeanServer with the registered singleton MBeans, so we're still unable to invoke the operations we need fom the singleton MBeans.


              --James

              • 4. Re: How to access HASingleton MBeans from a non-master clust
                Scott Stark Master

                Its up to you how the RMIAdaptor is deployed. If you deploy it as a singleton it will only be on the master node. Otherwise its on every node and you have to connect to the jndi service on the singleton node to lookup the correct RMIAdaptor.

                • 5. Re: How to access HASingleton MBeans from a non-master clust
                  James Adams Novice

                  So from what you're saying it appears that the solution is to use the RMIAdaptor/InvokerAdaptorService as an HASingleton. This way I will always get an RMIAdaptor which has access to the other HASingleton MBeans as long as I do the lookup of the RMIAdaptor using HAJNDI in my Servlets and EJBs.

                  I'm not sure how I should go about deploying the service as a singleton. Do I want to move the entire jmx-invoker-adaptor-server.sar to the deploy-hasingleton directory ? Where do I put the HASingletonController mbean entry for the InvokerAdaptorService -- directly in the jboss-service.xml which is in the jmx-invoker-adaptor-server.sar, or in a separate jboss-service.xml in the deploy-hasingleton directory ? Do I use the start and stop lifecycle operations of the InvokerAdaptorService as the TargetStartMethod and TargetStopMethod for the HASingletonController ?

                  Thanks again for your help with this.


                  --James

                  • 6. Re: How to access HASingleton MBeans from a non-master clust
                    James Adams Novice

                    This doesn't work as I was hoping. I have added the below to JBOSS3.2.5/server/all/deploy/jmx-invoker-adaptor-server.sar/META-INF/jboss-service.xml:

                     <!-- HASingletonController to run the above MBean as a singleton -->
                     <mbean code="org.jboss.ha.singleton.HASingletonController"
                     name="jboss.hasingleton:service=RMIAdaptorSingletonController">
                     <depends>jboss:service=DefaultPartition</depends>
                     <depends>jboss.jmx:type=adaptor,name=Invoker</depends>
                     <attribute name="TargetName">jboss.jmx:type=adaptor,name=Invoker</attribute>
                     <attribute name="TargetStartMethod">start</attribute>
                     <attribute name="TargetStopMethod">stop</attribute>
                     </mbean>
                    </server>
                    


                    With this configuration I can start JBoss cluster nodes with no errors.


                    In a Servlet I am using the RMIAdaptor like so:

                     // get the InitialContext and lookup the RMIAdaptor
                     Context context = new InitialContext();
                     RMIAdaptor rmiAdaptor = (RMIAdaptor) context.lookup("jmx/rmi/RMIAdaptor");
                    
                     // if we have an RMIAdaptor and the AllUserInfo MBean is registered with it then we can invoke operations
                     if ((rmiAdaptor != null) && (rmiAdaptor.isRegistered(new ObjectName("grover.mbean:service=AllUserInfo"))))
                     {
                     // find out if the user is already in the table or not
                     Boolean isUserInTable = (Boolean) rmiAdaptor.invoke(new ObjectName("grover.mbean:service=AllUserInfo"),
                     "isUserInTable",
                     new Object[]{loginId},
                     new String[]{"java.lang.String"});
                    
                     // if the user is in the table already then get their info
                     if (isUserInTable.booleanValue())
                     {
                     // get the pre-existing user's information
                     userInfo = (UserInfo) rmiAdaptor.invoke(new ObjectName("grover.mbean:service=AllUserInfo"),
                     "getUserInfo",
                     new Object[]{loginId},
                     new String[]{"java.lang.String"});
                     }
                     else
                     {
                     // create and populate a new user information object
                     userInfo = new UserInfo();
                     userInfo.setLoginTime(Calendar.getInstance());
                     userInfo.setUserId(loginId);
                     userInfo.setUserType(0); // 0 = HIM, 1 = WEB
                     }
                    
                     // add this user's info to the MBean
                     rmiAdaptor.invoke(new ObjectName("grover.mbean:service=AllUserInfo"),
                     "addUserInfo",
                     new Object[]{userInfo},
                     new String[]{"com.hsp.grover.util.UserInfo"});
                     }
                     else
                     {
                     // log the error
                     m_logger.error("Unable to find an RMIAdaptor with a registered AllUserInfo singleton MBean");
                    
                     // throw an exception
                     throw new ServletException("Unable to find an RMIAdaptor with a registered AllUserInfo singleton MBean");
                     }
                    


                    On the master node this works fine, but when I run the Servlet from a second node I get an error because the RMIAdaptor does not have the singleton MBean registered. So the same exact problem as before.

                    I thought that this might be rectified by moving the entire jmx-invoker-adaptor-server.sar into the deploy-hasingleton directory. On the first (master) node this was no trouble, but on the second node I got loads of errors when I started JBoss, for example:

                    17:44:41,961 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=file:/export/jboss-3.2.5/se
                    rver/all/tmp/deploy/tmp448web-console.war/
                    17:44:42,165 INFO [STDOUT] java.lang.NullPointerException
                    17:44:42,168 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap.hash(ConcurrentReaderHashMap.java:298)
                    17:44:42,169 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap.get(ConcurrentReaderHashMap.java:410)
                    17:44:42,169 INFO [STDOUT] at org.jboss.system.Registry.lookup(Registry.java:51)
                    17:44:42,169 INFO [STDOUT] at org.jboss.console.plugins.helpers.AbstractPluginWrapper.findPluginManager(AbstractPluginWrapper.java:252)
                    17:44:42,169 INFO [STDOUT] at org.jboss.console.plugins.helpers.AbstractPluginWrapper.init(AbstractPluginWrapper.java:98)
                    17:44:42,169 INFO [STDOUT] at org.jboss.console.plugins.helpers.ServletPluginHelper.init(ServletPluginHelper.java:61)
                    17:44:42,170 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
                    17:44:42,170 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
                    17:44:42,170 INFO [STDOUT] at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
                    17:44:42,170 INFO [STDOUT] at org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
                    17:44:42,170 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
                    17:44:42,170 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
                    17:44:42,170 INFO [STDOUT] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
                    17:44:42,171 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    17:44:42,171 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    17:44:42,171 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,171 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,171 INFO [STDOUT] at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
                    17:44:42,171 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:109)
                    17:44:42,172 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,172 INFO [STDOUT] at org.apache.catalina.core.StandardContext.init(StandardContext.java:5412)
                    17:44:42,172 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    17:44:42,172 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    17:44:42,172 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,172 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,172 INFO [STDOUT] at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
                    17:44:42,173 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:109)
                    17:44:42,173 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,173 INFO [STDOUT] at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:286)
                    17:44:42,173 INFO [STDOUT] at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:70)
                    17:44:42,173 INFO [STDOUT] at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:306)
                    17:44:42,173 INFO [STDOUT] at org.jboss.web.WebModule.startModule(WebModule.java:62)
                    17:44:42,174 INFO [STDOUT] at org.jboss.web.WebModule.startService(WebModule.java:40)
                    17:44:42,174 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
                    17:44:42,174 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
                    17:44:42,174 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                    17:44:42,174 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,174 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,174 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                    17:44:42,175 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                    17:44:42,175 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                    17:44:42,175 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                    17:44:42,175 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                    17:44:42,175 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,175 INFO [STDOUT] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:837)
                    17:44:42,176 INFO [STDOUT] at $Proxy17.start(Unknown Source)
                    17:44:42,176 INFO [STDOUT] at org.jboss.system.ServiceController.start(ServiceController.java:367)
                    17:44:42,176 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                    17:44:42,176 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,176 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,176 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                    17:44:42,176 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                    17:44:42,177 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                    17:44:42,177 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                    17:44:42,177 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                    17:44:42,177 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,177 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    17:44:42,177 INFO [STDOUT] at $Proxy40.start(Unknown Source)
                    17:44:42,178 INFO [STDOUT] at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:313)
                    17:44:42,178 INFO [STDOUT] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:836)
                    17:44:42,178 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:645)
                    17:44:42,178 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
                    17:44:42,178 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
                    17:44:42,178 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,178 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,179 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                    17:44:42,179 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                    17:44:42,179 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                    17:44:42,179 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                    17:44:42,179 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                    17:44:42,179 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,179 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    17:44:42,180 INFO [STDOUT] at $Proxy7.deploy(Unknown Source)
                    17:44:42,180 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:304)
                    17:44:42,180 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:478)
                    17:44:42,180 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
                    17:44:42,180 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
                    17:44:42,180 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
                    17:44:42,181 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
                    17:44:42,181 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                    17:44:42,181 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,181 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,181 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                    17:44:42,181 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                    17:44:42,182 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                    17:44:42,182 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                    17:44:42,182 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                    17:44:42,182 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,182 INFO [STDOUT] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:837)
                    17:44:42,182 INFO [STDOUT] at $Proxy0.start(Unknown Source)
                    17:44:42,182 INFO [STDOUT] at org.jboss.system.ServiceController.start(ServiceController.java:367)
                    17:44:42,183 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                    17:44:42,183 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,183 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,183 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                    17:44:42,183 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                    17:44:42,183 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                    17:44:42,184 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                    17:44:42,184 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                    17:44:42,184 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,184 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    17:44:42,184 INFO [STDOUT] at $Proxy4.start(Unknown Source)
                    17:44:42,184 INFO [STDOUT] at org.jboss.deployment.SARDeployer.start(SARDeployer.java:251)
                    17:44:42,184 INFO [STDOUT] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:836)
                    17:44:42,185 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:645)
                    17:44:42,185 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
                    17:44:42,185 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:592)
                    17:44:42,185 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    17:44:42,185 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    17:44:42,185 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    17:44:42,185 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
                    17:44:42,186 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                    17:44:42,186 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                    17:44:42,186 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                    17:44:42,186 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                    17:44:42,186 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                    17:44:42,186 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                    17:44:42,187 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    17:44:42,187 INFO [STDOUT] at $Proxy5.deploy(Unknown Source)
                    17:44:42,187 INFO [STDOUT] at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:407)
                    17:44:42,187 INFO [STDOUT] at org.jboss.system.server.ServerImpl.start(ServerImpl.java:311)
                    17:44:42,187 INFO [STDOUT] at org.jboss.Main.boot(Main.java:145)
                    17:44:42,187 INFO [STDOUT] at org.jboss.Main$1.run(Main.java:399)
                    17:44:42,187 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)
                    17:44:42,191 ERROR [Engine] StandardContext[/web-console]Servlet /web-console threw load() exception javax.servlet.ServletException
                     at org.jboss.console.plugins.helpers.ServletPluginHelper.init(ServletPluginHelper.java:66)
                     at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
                     at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
                     at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
                     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
                     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
                     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
                     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:324)
                     at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
                     at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:109)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                     at org.apache.catalina.core.StandardContext.init(StandardContext.java:5412)
                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:324)
                     at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
                     at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:109)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                     at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:286)
                     at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:70)
                     at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:306)
                     at org.jboss.web.WebModule.startModule(WebModule.java:62)
                     at org.jboss.web.WebModule.startService(WebModule.java:40)
                     at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
                     at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
                     at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:324)
                     at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                     at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:837)
                     at $Proxy17.start(Unknown Source)
                     at org.jboss.system.ServiceController.start(ServiceController.java:367)
                     at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:324)
                     at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                    
                     etc...
                    
                    



                    Any other ideas/suggestions ?


                    --James

                    • 7. Re: How to access HASingleton MBeans from a non-master clust
                      James Adams Novice

                       

                      "scott.stark@jboss.org" wrote:
                      Otherwise its on every node and you have to connect to the jndi service on the singleton node to lookup the correct RMIAdaptor.


                      How would I determine at run time which node is the master node ? If I don't know this then how could I specify a lookup of an object running on a certain node ? Wouldn't this require me to specify another NamingService port number for the InitialContext, one which matches to the master node ? Are any code examples of this available anywhere ?

                      --James

                      • 8. Re: How to access HASingleton MBeans from a non-master clust
                        Scott Stark Master

                        The web-console uses the RMIAdaptor as well, so either remove that or deploy a second copy of the jmx-invoker-adaptor-server.sar using a second jndi name and deploy that as the singleton version.

                        • 9. Re: How to access HASingleton MBeans from a non-master clust
                          James Adams Novice

                          I have worked this out and can access the RMIAdaptor from a non-master node. Here is the jboss-service.xml of the jmx-invoker-adaptor-server.sar which was copied from deploy to deploy-hasingleton:

                          <?xml version="1.0" encoding="UTF-8"?>
                          
                          <!-- $Id: jboss-service.xml,v 1.1.2.9 2004/03/15 08:19:03 ejort Exp $ -->
                          <server>
                          
                           <!-- The JRMP invoker proxy configuration for the InvokerAdaptorService -->
                           <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
                           name="jboss.jmx:type=adaptor,name=SingletonInvoker,protocol=jrmp,service=proxyFactory">
                           <!-- Use the standard JRMPInvoker from conf/jboss-service.xxml -->
                           <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmp</depends>
                           <!-- The target MBean is the InvokerAdaptorService configured below -->
                           <depends optional-attribute-name="TargetName">jboss.jmx:type=adaptor,name=SingletonInvoker</depends>
                           <!-- Where to bind the RMIAdaptor proxy -->
                           <attribute name="JndiName">jmx/invoker/SingletonRMIAdaptor</attribute>
                           <!-- The RMI compabitle MBeanServer interface -->
                           <attribute name="ExportedInterfaces">org.jboss.jmx.adaptor.rmi.RMIAdaptor,
                           org.jboss.jmx.adaptor.rmi.RMIAdaptorExt
                           </attribute>
                           <attribute name="ClientInterceptors">
                           <interceptors>
                           <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
                           <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
                           <interceptor>org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor</interceptor>
                           <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
                           </interceptors>
                           </attribute>
                           </mbean>
                          
                           <!-- 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=SingletonInvoker"
                           xmbean-dd="">
                           <xmbean>
                           <description>The JMX Detached Invoker Service</description>
                           <class>org.jboss.jmx.connector.invoker.InvokerAdaptorService</class>
                          
                           <!-- Attributes -->
                           <attribute access="read-only" getMethod="getName">
                           <description>The class name of the MBean</description>
                           <name>Name</name>
                           <type>java.lang.String</type>
                           </attribute>
                           <attribute access="read-only" getMethod="getState">
                           <description>The status of the MBean</description>
                           <name>State</name>
                           <type>int</type>
                           </attribute>
                           <attribute access="read-only" getMethod="getStateString">
                           <description>The status of the MBean in text form</description>
                           <name>StateString</name>
                           <type>java.lang.String</type>
                           </attribute>
                           <attribute access="read-write" getMethod="getExportedInterfaces" setMethod="setExportedInterfaces">
                           <description>The interfaces the invoker proxy supports</description>
                           <name>ExportedInterfaces</name>
                           <type>[Ljava.lang.Class;</type>
                           </attribute>
                           <attribute access="read-only" getMethod="getMethodMap">
                           <description>Map(Long hash, Method) of the proxy interface methods</description>
                           <name>MethodMap</name>
                           <type>java.util.Map</type>
                           </attribute>
                           <!-- Operations -->
                           <operation>
                           <description>The start lifecycle operation</description>
                           <name>start</name>
                           </operation>
                           <operation>
                           <description>The stop lifecycle operation</description>
                           <name>stop</name>
                           </operation>
                           <operation>
                           <description>The detyped lifecycle operation (for internal use only)</description>
                           <name>jbossInternalLifecycle</name>
                           <parameter>
                           <description>The lifecycle operation</description>
                           <name>method</name>
                           <type>java.lang.String</type>
                           </parameter>
                           <return-type>void</return-type>
                           </operation>
                          
                           <operation>
                           <description>The detached invoker entry point</description>
                           <name>invoke</name>
                           <parameter>
                           <description>The method invocation context</description>
                           <name>invocation</name>
                           <type>org.jboss.invocation.Invocation</type>
                           </parameter>
                           <return-type>java.lang.Object</return-type>
                           <!-- Uncomment to require authenticated users
                           <descriptors>
                           <interceptors>
                           <interceptor code="org.jboss.jmx.connector.invoker.AuthenticationInterceptor"
                           securityDomain="java:/jaas/jmx-console"/>
                           </interceptors>
                           </descriptors>
                           -->
                           </operation>
                           </xmbean>
                           <attribute name="ExportedInterfaces">org.jboss.jmx.adaptor.rmi.RMIAdaptor,
                           org.jboss.jmx.adaptor.rmi.RMIAdaptorExt
                           </attribute>
                           </mbean>
                          
                           <!-- HASingletonController to run the above MBean as a singleton -->
                           <mbean code="org.jboss.ha.singleton.HASingletonController"
                           name="jboss.hasingleton:service=RMIAdaptorSingletonController">
                           <depends>jboss:service=DefaultPartition</depends>
                           <depends>jboss.jmx:type=adaptor,name=SingletonInvoker</depends>
                           <attribute name="TargetName">jboss.jmx:type=adaptor,name=Invoker</attribute>
                           <attribute name="TargetStartMethod">start</attribute>
                           <attribute name="TargetStopMethod">stop</attribute>
                           </mbean>
                          
                          </server>
                          


                          Notice that the original NamingAlias entry was removed, and both the JndiName and name of the JRMPProxyFactory were modified.

                          Now the trouble is not that I can't find the RMIAdaptor, but once I do it complains of the wrong number of arguments when I use the RMIAdaptor.invoke() method, even though I am using the correct number of arguments as specified on p. 92 of the JBoss 3.2.3 Admin/Dev Guide. Here is the offending code:

                           // add this user's info to the singleton MBean
                           rmiAdaptor.invoke(new ObjectName("grover.mbean:service=AllUserInfo"),
                           "addUserInfo",
                           new Object[]{userInfo},
                           new String[]{"com.hsp.grover.util.UserInfo"});
                          


                          The error messages I get from JBoss:

                          2004-10-21 16:33:53,110 ERROR [org.jboss.web.localhost.Engine] StandardWrapperValve[GetPreferencesServlet]:
                          Servlet.service() for servlet GetPreferencesServlet threw exception
                          java.lang.IllegalArgumentException: wrong number of arguments
                           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                           at java.lang.reflect.Method.invoke(Method.java:324)
                           at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:250)
                           at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
                           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                           at java.lang.reflect.Method.invoke(Method.java:324)
                           at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
                           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
                           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
                           at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
                           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
                           at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
                           at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source)
                           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                           at java.lang.reflect.Method.invoke(Method.java:324)
                           at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                           at sun.rmi.transport.Transport$1.run(Transport.java:148)
                           at java.security.AccessController.doPrivileged(Native Method)
                           at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                           at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                           at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                           at java.lang.Thread.run(Thread.java:534)
                           at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
                           at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
                           at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
                           at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
                           at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
                           at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
                           at org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor.invoke(InvokerAdaptorClientInterceptor.java:58)
                           at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:53)
                           at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:55)
                           at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
                           at $Proxy202.invoke(Unknown Source)
                           at com.harborsideplus.grover.servlet.GetPreferencesServlet.doGet(GetPreferencesServlet.java:307)
                           at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
                           at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
                           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
                           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
                           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
                           at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
                           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
                           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
                           at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
                           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
                           at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:78)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
                           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
                           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
                           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
                           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
                           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                           at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
                           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
                           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
                           at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
                           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
                           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
                           at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
                           at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
                           at java.lang.Thread.run(Thread.java:534)
                          


                          It is quite strange because I have used the RMIAdaptor.invoke() method a few lines earlier in this doGet() with no errors using the same number and type of arguments.

                          Does anyone have any ideas as to why this is happening ?


                          --James

                          • 10. Re: How to access HASingleton MBeans from a non-master clust
                            James Adams Novice

                            This illegal argment error has mysteriously disappeared. The RMIAdaptor now appears to be working for me as advertised. Hallelujah !

                            --James