Announcement Announcement Module
Collapse
No announcement yet.
Why are Attributes also Operations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why are Attributes also Operations

    Why are all attributes also exposed as Operations as well? Is that a JMX requirement or spring? I am using MetaDataAssembler(using 1.5 Annotations )

    It doesnt appear that the standard mbeans within the jvm expose their attributes as operations. Doing so seems redundant.

    Also a side effect is that I cant have a @ManagedOperation that starts with get/set since this method will appear to look like an attribute, but doesnt have the @ManagedAttribute and so will get ignored by the assembler.

    Any insights are welcome.

    thanks for the jmx support. It has save alot of time.

  • #2
    That was my question too, last week.

    JConsole, and MX4J http-adaptor show both an error like:

    Error during MBean operation invocationMessage: null nested exception is javax.management.ServiceNotFoundException: Operation descriptor field 'role' must be 'operation', not getter'

    after invoking these 'getter-operations'.


    Commenting out
    Code:
    					// Attributes need to have their methods exposed as
    					// operations to the JMX server as well.
    					info = createModelMBeanOperationInfo(method, pd.getName(), beanKey);
    					Descriptor desc = info.getDescriptor();
    					if (method.equals(pd.getReadMethod())) {
    						desc.setField(FIELD_ROLE, ROLE_GETTER);
    					}
    					else {
    						desc.setField(FIELD_ROLE, ROLE_SETTER);
    					}
    					desc.setField(FIELD_VISIBILITY, ATTRIBUTE_OPERATION_VISIBILITY);
    					if (isExposeClassDescriptor()) {
    						desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName());
    					}
    					info.setDescriptor(desc);
    in
    Code:
    protected ModelMBeanOperationInfo[] getOperationInfo(Object managedBean, String beanKey)
    from
    Code:
    org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.java
    seems to work for me...

    Comment


    • #3
      Operation descriptor field role must be operation, not getter

      I experienced same problems. I have a method in my bean called "getLoggerNames" which is causing "Operation descriptor field role must be 'operation', not getter" Service Exception. After changing my method name to "accessLoggerNames", everything started working fine. method is returning proper data when I called using WebSphere AdminClient interface.

      WebSphere 6
      AIX
      Spring 1.2.8

      MBEAN IMPL


      public class ApplicationLogInfoBean implements IApplicationLogBean {

      public String[] accessLoggerNames(){

      Enumeration loggersEnum = Logger.getRootLogger().getLoggerRepository().getCu rrentLoggers();
      List loggerNames = new ArrayList(25);

      while(loggersEnum.hasMoreElements()){
      Logger logger = (Logger) loggersEnum.nextElement();

      if(logger.getAllAppenders().hasMoreElements()){

      loggerNames.add(logger.getName());
      }

      }

      String[] names = new String[loggerNames.size()];
      return (String[] ) loggerNames.toArray(names);
      }


      }




      CLIENT:

      AdminClient adminClient;

      Properties connectProps = new Properties();
      connectProps.setProperty(AdminClient.CONNECTOR_TYP E, AdminClient.CONNECTOR_TYPE_SOAP);
      connectProps.setProperty(AdminClient.CONNECTOR_HOS T, "localhost");
      connectProps.setProperty(AdminClient.CONNECTOR_POR T, "8882");

      // Get an AdminClient based on the connector properties
      try
      {
      adminClient = AdminClientFactory.createAdminClient(connectProps) ;


      String query = "*rocess=server1,*";
      ObjectName queryName = new ObjectName(query);
      Set s = adminClient.queryNames(queryName, null);

      Iterator ites = s.iterator();

      while(ites.hasNext()){

      ObjectName objectName = (ObjectName)ites.next();
      String name = objectName.getKeyProperty("name") ;

      if(name.equalsIgnoreCase("Log4JWrapperBean")){


      Object ob = adminClient.invoke(objectName, "accessLoggerNames", null, null);

      String[] logNames = (String[]) ob;

      for(int i =0; i <logNames.length; i++){


      System.out.println(logNames[i]);
      }

      }








      }




      }
      catch (ConnectorException e)
      {
      System.out.println("Exception creating admin client: " + e);

      }





      SPRING CONFIG


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
      "http://www.springframework.org/dtd/spring-beans.dtd">

      <beans>


      <bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r" lazy-init="false">

      <property name="beans">
      <map>
      <entry key="Log4JWrapperBean" value-ref="testBean"/>


      </map>
      </property>

      <property name="assembler">
      <bean class="org.springframework.jmx.export.assembler.In terfaceBasedMBeanInfoAssembler">
      <property name="managedInterfaces">
      <value>XXXX.XXXXX.IApplicationLogBean</value>
      </property>
      </bean>
      </property>

      <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>
      <property name="server" ref="mbeanServer" />
      <property name="namingStrategy" ref="websphereNamingStrategy"/>


      <property name="listeners">
      <list>

      </list>
      </property>

      </bean>


      <bean id="testBean" class="XXXX.XXXXXXXX.XXXXXXXXX.ApplicationLogInfoB ean">

      </bean>

      <bean id="mbeanServer" class="XXXXXXXX.XXXXXXXXX.WebSphereMBeanServerFact oryBean" />

      <bean id="adminService" class="com.ibm.websphere.management.AdminServiceFa ctory" factory-method="getAdminService"/>

      <bean id="adminService.defaultDomain" class="org.springframework.beans.factory.config.Pr opertyPathFactoryBean"/>
      <bean id="adminService.cellName" class="org.springframework.beans.factory.config.Pr opertyPathFactoryBean"/>
      <bean id="adminService.nodeName" class="org.springframework.beans.factory.config.Pr opertyPathFactoryBean"/>
      <bean id="adminService.processName" class="org.springframework.beans.factory.config.Pr opertyPathFactoryBean"/>

      <bean id="websphereNamingStrategy" class="XXXXXXXXXXX.XXXXXXXXXX.WebsphereNamingStrat egy">
      <property name="domainName" ref="adminService.defaultDomain"/>
      <property name="cellName" ref="adminService.cellName"/>
      <property name="nodeName" ref="adminService.nodeName"/>
      <property name="processName" ref="adminService.processName"/>
      </bean>


      </beans>
      Last edited by bred; Jul 31st, 2008, 08:47 PM.

      Comment

      Working...
      X