4 Replies Latest reply on May 23, 2005 1:30 PM by Paul Hildebrand

    Requesting data from multiple servers using JMX, all give sa

    Paul Hildebrand Newbie

      We hava a small farm of servers running JBoss 4.0.1. On a certain webpage we can see how many active sessions are running on each server. Since we upgraded from JBoss 3.0.8 to 4.0.1 all servers report the same amount of sessions.

      If I run the following code from the command line all works perfectly. But if I run (roughly) the same code in a servlet or strutsaction all servers report the same amount of sessions. Does JBoss cache the RMIAdaptor? What am I doing wrong?

      public class JMXBrowser
       public static InitialContext getContext(String serverUrl)throws NamingException
       Properties props = new Properties();
       props.put(Context.PROVIDER_URL, serverUrl);
       InitialContext ic = new InitialContext(props);
       return ic;
       * @param args the command line arguments
       public static void main(String[] args) throws Exception
       String[] servers = new String[2];
       servers[0] = "";
       servers[1] = "";
       for (int i=0; i < servers.length; i++)
       InitialContext ctx = getContext(servers[ i ]);
       RMIAdaptor adaptor = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
       Integer count = (Integer) adaptor.getAttribute(new ObjectName("plato:service=WebAppService"), "ActiveHttpSessionCount");
       System.out.println("Server " + servers[ i ] + ": #sessions: " + count);