5 Replies Latest reply on Nov 17, 2004 8:51 AM by swapna prasad

    remote management of JBoss from a universal client

    swapna prasad Newbie

      I am Developing a universal client to manage multiple JMX enabled applications remotely. This prevents me from having any of the application specific jar files in my classpath. My question is..
      1. Is it possible to manage JBoss in such a way.
      - In Jboss3.2.6 I see RMIAdaptorExt interface in jbossall-client.jar which extends MBeanServerConnection and Remote. Is this bound to the registry, if so what is its bind name. Can I lookup on this object and cast it to MBeanServer Interface.
      2. Is JBoss JSR160 compliant. If so which version of Jboss is ?
      Any help in this regards is highly appreciated

        • 1. Re: remote management of JBoss from a universal client
          Dimitris Andreadis Master

          RMIAdaptor is registered under:
          jmx/rmi/RMIAdaptor
          You can cast to to MBeanServerConnection and do your stuff.

          JBoss is not fully JSR160 compliant (yet).

          You'll need at least some of the jboss classes in your classpath. Another option is to allow dynamic classloading. JBoss serves classes from port 8083

          • 2. Re: remote management of JBoss from a universal client
            swapna prasad Newbie

            should I use jnp or can I use sun's rmi context factory for lookup. when i try using sun's rmi and lookup for jmx/rmi/RMIAdaptor I get a noSuchObjectException. Please advice

            • 3. Re: remote management of JBoss from a universal client
              Dimitris Andreadis Master

              You must use jnp to reach the JBoss JNDI provider

              • 4. Re: remote management of JBoss from a universal client
                Anil Saldanha Master

                Be Happy. Here is sample code thats shows how to connect to RMIAdaptor. This code is in JBoss Testsuite.

                package org.jboss.test;
                
                
                import javax.naming.*;
                import javax.management.*;
                import java.util.*;
                import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
                import org.apache.log4j.Category;
                
                
                /** Helper Class that connects to the RMA Adaptor on any JBoss node
                 * to provide some services like start/stop JBoss services registered
                 * in the MBean server.
                 *
                 * @author Anil.Saldhana@jboss.org
                 * @version $Revision: 1.2 $
                 */
                
                public class JBossRMIAdaptorHelper
                {
                 protected RMIAdaptor rmiserver = null;
                 protected Category log;
                
                 /**
                 * Constructor
                 */
                 public JBossRMIAdaptorHelper()
                 {
                 log = Category.getInstance(this.getClass().getName());
                 }
                
                 /**
                 * Constructor that takes a JNDI url
                 * @param jndiurl JNDI Url (jnp://localhost:1099)
                 */
                 public JBossRMIAdaptorHelper( String jndiurl ){
                 this();
                 try {
                 //Set Some JNDI Properties
                 Hashtable env = new Hashtable();
                 env.put( Context.PROVIDER_URL, jndiurl );
                 env.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                 env.put( Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
                
                 InitialContext ctx = new InitialContext(env);
                 rmiserver = (RMIAdaptor) ctx.lookup("jmx/rmi/RMIAdaptor");
                 if( rmiserver == null ) log.debug( "RMIAdaptor is null");
                 }catch( Exception e){
                 log.debug(e);
                 }
                 }
                
                 /**
                 * Get the Metadata for the MBean
                 * @param oname ObjectName of the MBean
                 * @return MBeanInfo about the MBean
                 */
                 public MBeanInfo getMBeanInfo( ObjectName oname ){
                 /* Example:
                 //Get the MBeanInfo for the Tomcat MBean
                 ObjectName name = new ObjectName( "jboss.web:service=WebServer" );
                 */
                 MBeanInfo info = null;
                
                 try{
                 info = rmiserver.getMBeanInfo( oname );
                 } catch( Exception e){
                 log.debug(e);
                 }
                 return info;
                 }
                
                 /**
                 * Invoke an Operation on the MBean
                 * @param oname ObjectName of the MBean
                 * @param methodname Name of the operation on the MBean
                 * @param pParams Arguments to the operation
                 * @param pSignature Signature for the operation.
                 * @return result from the MBean operation
                 * @throws Exception
                 */
                 public Object invokeOperation( ObjectName oname,
                 String methodname,Object[] pParams,
                 String[] pSignature )
                 throws Exception {
                 Object result = null;
                 try{
                 /* Example:
                 //Stop the Tomcat Instance
                 Object result = server.invoke(name, "stop",null,null);
                 */
                 result = rmiserver.invoke(oname, methodname ,pParams,pSignature);
                 } catch( Exception e){
                 log.debug( e);
                 }
                
                 return result;
                 }
                
                
                }//end class


                • 5. Re: remote management of JBoss from a universal client
                  swapna prasad Newbie

                  JBoss has many configuration files.
                  Is there a relationship(organizational or structural) between jboss xml conf file and the domain name.
                  i.e. e.g. say jboss-service.xml information can be obtained by querying mbeans in the domain "jboss.service:*" and the structure of the jboss-service.xml matches the attributes fetched by getAttributes on the mbeans fetched in that domain.
                  I am trying to match the conf xml files to attributes got from mbeans.

                  Hope I am clear. Please advice.

                  Thanks in advance