0 Replies Latest reply on Feb 28, 2006 5:50 AM by alex mora

    Locating MBeanServer from EJB: MBeanServerLocator.locate() d

    alex mora Newbie

      JBoss: ver 4.0.3 SP1 (it's the same with 4.04) installing "all" packets
      JVM: 1.5.0_05
      IDE: Netbeans 5 beta

      I need to get access to the TreeCache from a servlet. So i used a EJB that find the TreeCacheMBeans and manage it. And a Servlet that lookup and use the EJB
      When i look for the MBeanServer from inside the EJB with the code:

      server = MBeanServerLocator.locatejboss();
      

      the MBeanServerLocator throws an exception:
      java.lang.RuntimeException: javax.ejb.CreateException: java.lang.IllegalStateException: No 'jboss' MBeanServer found!

      It doesn't work also if I use MBeanServerLocator.locate() instead of MBeanServerLocator.locatejboss().
      The method .locate() throws java.util.NoSuchElementException.

      The only way i found to get the MBeanServer is using this code from inside the SERVLET:
      List servers=MBeanServerFactory.findMBeanServer(null);
       if(servers == null || servers.size() == 0)
       throw new Exception("TreeCacheView.init(): no MBeanServers found");
       server=(MBeanServer)servers.get(0);

      But this DOESN'T work inside the EJB!! How is it?
      How is it possible to find the MBeanServer from the EJB?

      Thanks!