tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Guarnieri" <peter.guarni...@appian.com>
Subject Can't get StandardManager Mbean from Mbean server
Date Wed, 19 Oct 2005 22:35:39 GMT
Hi all,

I'm currently trying to write some code to monitor active sessions in my
web-app. I've got the following code written to find the MBean
representing the context of my web-app, and pull out the StandardManager
object:

 

MBeanServer mBeanServer = null;

                        

                        try 

                        {

                                    ArrayList servers =
MBeanServerFactory.findMBeanServer(null);

                                    

                                    

                                    mBeanServer = (MBeanServer)
servers.get(0);

                                    System.out.println("MBeanServer 1 :
" + mBeanServer);

                                    

                                    

                                    

                                    int k = 0;

            

                                    System.out.println("trying to get
suite mbean:");

                                    ObjectName objName = new
ObjectName("Catalina:j2eeType=WebModule,name=//localhost/suite,J2EEAppli
cation=none,J2EEServer=none");

                                    Set mBeans =
mBeanServer.queryMBeans(objName,null);

                                    Iterator iter = mBeans.iterator();

            

                                    while(iter.hasNext())

                                    {

                                                ObjectInstance
objectInstance = (ObjectInstance )iter.next();

                                                MBeanInfo mBeanInfo =
mBeanServer.getMBeanInfo(objectInstance.getObjectName());       

                                                for(int j = 0; j <
mBeanInfo.getAttributes().length; j++)

                                                {

 
MBeanAttributeInfo mBeanAttributeInfo = mBeanInfo.getAttributes()[j];

                                                            Object att =
mBeanServer.getAttribute(objectInstance.getObjectName(),
mBeanAttributeInfo.getName());

                                                            

                                                            try

                                                            {

 
org.apache.catalina.session.StandardManager manager =
(org.apache.catalina.session.StandardManager)att;

                                                            }

 
catch(Exception e)

                                                            {

 
LOG.error("couldn't cast " +att+ ": " +e);

                                                            }

                                                }

                                                

                                    

                                    }

                                    

                        } 

                        catch (Exception e) 

                        {

                                    LOG.error("error in JMXTest: ",e);

                        }

                        

 

But the casting statement in there:

 

org.apache.catalina.session.StandardManager manager =
(org.apache.catalina.session.StandardManager)att;

 

... throws a ClassCastException. I've tried printing out the class name
of "att" before casting it, and it shows
org.apache.catalina.session.StandardManager.  I'm baffled at this point.
I'm compiling my app using the same catalina.jar that Tomcat is using.
Is there something I'm missing here? 

 

Specs:

Tomcat 5.0.28

WinXP sp1

J2sdk1.4.2_05

 

Thanks,

Peter


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message