2 Replies Latest reply on Apr 11, 2007 4:08 AM by Dimitris Andreadis

    XDOCLET tags and MBeans

    pawan1475 Newbie

      Hi,
      We are planning to upgrade our application from Jboss 4.0.3 to Jboss 4.0.5.GA and have been experiencing some issues with it. We have lots of mbeans defined in our system, but during the upgrade we are seeing lot of exceptions on accessing the mbeans that have the XDOCLET tag @jmx.managed-attribute. There are no changes to the code except the Jboss upgrade, I am wondering if somebody can help me understand the reason why this is happening. I am seeing MethodNotDefine, IllegalArgument exception (Standard Reflection exception when you invoke a method). The most wierd thing is when i changed the XDOCLET tag to @jmx.managed-operation impact = "INFO" everything works fine on the new Jboss server. Since there is a lot of core code, i am really reluctant to change.

      Regards

      Pawan Kharbanda

      /**
       * MBeanProxySupports
       *
       * Implements MBeanProxy
       *
       * @author westraj
       */
      public class MBeanProxySupports implements MBeanProxy {
       /**
       * Default serial version UID
       */
       private static final long serialVersionUID = 1L;
       private static final String EQUALS = "equals";
       private static final String HASH_CODE = "hashCode";
       private static final String TO_STRING = "toString";
      
       private MBeanServer server = null;
       private String mbeanName;
       private ObjectName objectName = null;
       private int hashCode = -1;
      
       private static int HASHCODE = 0;
       private static final Object lock = "";
      
       /**
       * Constructor
       * @throws MalformedObjectNameException if unacceptable name
       */
       public MBeanProxySupports(MBeanServer server, String mbeanName) throws MalformedObjectNameException {
       super();
       this.server = server;
       this.mbeanName = mbeanName;
       objectName = new ObjectName(mbeanName);
      
       synchronized(lock) {
       hashCode = HASHCODE++;
       }
       }
      
       /* (non-Javadoc)
       * @see cdot.util.MBeanProxy#getMBeanName()
       */
       public String getMBeanName() {
       return mbeanName;
       }
      
       /* (non-Javadoc)
       * @see cdot.util.MBeanProxy#getMBeanServer()
       */
       public MBeanServer getMBeanServer() {
       return server;
       }
      
       /* (non-Javadoc)
       * @see cdot.util.MBeanProxy#invoke(java.lang.String, java.lang.Object[], java.lang.String[])
       */
       public Object invoke(String methodName, Object[] methodParams,
       String[] signature) throws MBeanException {
      
       if (TO_STRING.equals(methodName)) {
       return objectName.toString();
       } else if (HASH_CODE.equals(methodName)) {
       return new Integer(hashCode);
       } else if (EQUALS.equals(methodName)) {
       return new Boolean(methodParams[0].equals(this));
       }
      
       Object result = null;
       try {
       result = server.invoke(objectName, methodName, methodParams, signature);
      
       } catch(InstanceNotFoundException ex) {
       throw new MBeanException(ex,"MBean '"+objectName+"' does not exist, which caused "+methodName+"() to fail.");
       } catch(RuntimeException ex) {
       throw new MBeanException(ex,"Exception caused "+methodName+"() to fail");
       } catch(ReflectionException ex) {
       throw new MBeanException(ex,"ReflectionException caused "+methodName+"() to fail.");
       }
      
       return result;
       }
      
       /* (non-Javadoc)
       * @see cdot.util.MBeanProxy#invoke(java.lang.String)
       */
       public Object invoke(String methodName) throws MBeanException {
       return invoke(methodName, null, null);
       }
      
       /**
       * Returns equality of two objects
       * @param object
       * @return boolean
       */
       public boolean equals(Object object) {
       if (!(object instanceof MBeanProxySupports)) {
       return false;
       }
       MBeanProxySupports other = (MBeanProxySupports)object;
       if (!other.mbeanName.equals(this.mbeanName)) {
       return false;
       }
      
       return true;
       }
      
      }
      
      
      // XDOCLET code in Mbean
      /**
       * @jmx.managed-attribute
       /**
       * @jmx.managed-operation
       * description="Returns HashMap for the Standard Fonts"
       *
       */
       public Hashtable getStandardFonts() {
       return super.getStandardFonts();
       }
      
      
      // Access code
      ServiceLocator serviceLocator = ServiceLocator.getInstance();
       MBeanProxy propMgrMBean = serviceLocator.getMBean(MBEAN_NAME);
       Hashtable stdFonts = null;
       Hashtable compFonts = null;
      
       try
       {
       stdFonts = (Hashtable ) propMgrMBean.invoke("getStandardFonts");