You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Honnavalli, Jyothi" <jy...@merck.com> on 2004/09/28 23:30:15 UTC

How to get a handle to tomcat Mbean Server?

Hi All,

I was just learning 'bt Mbeans. To begin with, I was learning to use and
test the Mbeans that are already existing in tomcat so I get to know how
Mbeans work.  I have written my own Agent called UserManager to call the
Mbeans to list users (Tomcat Admin functionality : based on classes
ApplicationServlet, UserUtils and ListUserServlet of tomcat source). I'm
just not able to get a handle to the correct Mbean server. Can I get a
handle to tomcat mbean server at all if I have to use it else where?? I'm
getting the below exception. Kindly let me know how do I get a handle to the
Mbean server from outside the Admin Application. I've used the same
parameters as used by the Admin application classes.  I'm using tomcat
5.0.25. Please tell me how to get a reference / handle to the Mbean server. 

 Application DUMP is okey  org.apache.webapp.admin.Application@affc70
log4j:WARN No appenders could be found for logger
(org.apache.commons.modeler.Re
gistry).
log4j:WARN Please initialize the log4j system properly.
listUsers :  UserUtil.getUsersForm(mserver,databaseName);
listUsers has Server ===> mx4j.server.MBeanServerImpl@26d4f1
listUsers has databaseName ===>
Users:type=UserDatabase,database=UserDatabase
In MBeanServer mserver = mx4j.server.MBeanServerImpl@26d4f1
   The obj is Users:type=UserDatabase,database=UserDatabase


javax.management.InstanceNotFoundException: MBeanServer cannot find MBean
with O
bjectName Users:type=UserDatabase,database=UserDatabase
        at
mx4j.server.MBeanServerImpl.findMBeanMetaData(MBeanServerImpl.java:52
8)
        at
mx4j.server.MBeanServerImpl.getAttribute(MBeanServerImpl.java:1235)
        at
org.apache.webapp.admin.users.UserUtil.getUsersForm(UserUtil.java:106
)
        at
org.apache.webapp.admin.users.UserManager.listUsers(UserManager.java:
198)
        at org.apache.webapp.admin.users.Jyo.main(Jyo.java:26)
List is Null
Press any key to continue . . .

Thanks,

Jyothi


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: How to get a handle to tomcat Mbean Server?

Posted by Robert Harper <ro...@iat-cti.com>.
I don't know if this helps but this is a function I use to load the user
database. After that, I use the different methods implemented in the
org.apache.catalina.UserDatabase class. I found the functions and the parameters
needed by searching the source for the function I wanted. I use this to
dynamically add and search for users. I can also add roles and add roles to
users.


private void loadUserDatabase()
{
  if(MBeanServerFactory.findMBeanServer(null).size() > 0)
  {
    m_BeanServer = (MBeanServer) BeanServerFactory.findMBeanServer(null).get(0);
  }
  else
  {
    m_BeanServer = MBeanServerFactory.createMBeanServer();
  }

  try
  {
    ObjectName obname = new ObjectName( userDB );
    MBeanInfo info = m_BeanServer.getMBeanInfo( obname );
    MBeanOperationInfo opInfo[] = info.getOperations();
    MBeanAttributeInfo atribInfo[] = info.getAttributes();
    for( int i = 0; i < opInfo.length; i++ )
    {
      log( "loadUserDatabase", "Operation: " + opInfo[i].getName() + " is
defined" );
    }

    for( int i = 0; i < atribInfo.length; i++ )
    {
      log( "loadUserDatabase", "Attribute: " + atribInfo[i].getName() + " = " +
m_BeanServer.getAttribute( obname, atribInfo[i].getName() ) );
    }
  }
  catch( Exception e )
  {
    e.printStackTrace();
  }
}

Robert S. Harper
801.265.8800 ex. 255
> -----Original Message-----
> From: Honnavalli, Jyothi [mailto:jyothi_honnavalli@merck.com]
> Sent: Tuesday, September 28, 2004 3:30 PM
> To: 'Tomcat Users List'
> Subject: How to get a handle to tomcat Mbean Server?
> 
> Hi All,
> 
> I was just learning 'bt Mbeans. To begin with, I was learning to use and
> test the Mbeans that are already existing in tomcat so I get to know how
> Mbeans work.  I have written my own Agent called UserManager to call the
[snip]




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org