3 Replies Latest reply on Oct 1, 2002 8:22 AM by adrian.brock

    How many EJBs deployed in JBoss

    stefus

      Hi all,
      I want to find out how many EJBs are deployed in JBoss. Is there a way to get the number of all EJBs in the server or is there a monitoring tool or something like that?

      Thanks for all replies.

      Regards
      Stefan

        • 1. Re: How many EJBs deployed in JBoss
          • 2. Re: How many EJBs deployed in JBoss
            stefus

            How can I do this from a Java Client. Have someone any code snippet for me.

            Regards
            Stefan

            • 3. Re: How many EJBs deployed in JBoss

              You'll needs some jars from ${jboss.dist}/client

              import java.util.*;
              import javax.management.*;
              import javax.naming.*;
              import org.jboss.jmx.adaptor.rmi.*;
              import org.jboss.jmx.connector.*;
              import org.jboss.jmx.connector.rmi.*;

              public class Client
              {
              public static void main(String[] args)
              throws Exception
              {
              // Set up jndi properties
              Properties 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");
              props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
              InitialContext ctx = new InitialContext(props);

              // Retrieve the RMI adaptor
              Object obj = ctx.lookup("jmx:local:rmi");
              ctx.close();

              // Wrap it in a connector
              RemoteMBeanServer server = new RMIConnectorImpl((RMIAdaptor)obj);

              // Print the EJB count
              System.out.println(server.queryMBeans(new ObjectName("jboss.j2ee:service=EJB,*"), null).size());
              }
              }