3 Replies Latest reply on Apr 4, 2002 7:20 AM by adrian.brock

    how to access MBeanServer

    dirk.haase

      Hi,

      I need to flush the security domain authentication cache. I found that little code snippet in the JBoss dokumentation that starts with
      MBeanServer server = ...;
      Unfortunately, I have no clue how to get the MBeanServer, i.e. I dont know how to completet this line. Could somebody please help me on this?

      thanks,
      Jex

        • 1. Re: how to access MBeanServer

          MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).iterator().next();

          There is only one MBeanServer in JBoss.

          Regards,
          Adrian

          • 2. Re: how to access MBeanServer
            dirk.haase

            thanks, that worked. At least it didnt cause any errors. But I still cant seem to flush the cache. Maybe you also have an idea what wrong with this code :

            MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).iterator().next();
            ObjectName jaasMgr = new ObjectName("Security:name=JaasSecurityManager");
            Object[] params = {"java:/jaas/usermgmt-secure"};
            String[] signature = {"java.lang.String"};
            server.invoke(jaasMgr, "flushAuthenticationCache", params, signature);
            log.info("Cache flushed.");

            in jboss.xml I have following line
            <security-domain>java:/jaas/usermgmt-secure</security-domain>
            to set the security domain. Is this the String I need to use as parameter in the invoke statement?

            thanks,
            Jex

            • 3. Re: how to access MBeanServer

              This is probably a question for the security forum.
              Your JMX code looks fine, whether you are passing the
              correct value is another question.

              NOTE: jboss.xml isn't used here. You are going outside
              the container when you access JMX directly.

              Regards,
              Adrian