Announcement Announcement Module
Collapse
No announcement yet.
No ManagedResource attribute found for class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No ManagedResource attribute found for class

    HI ,

    I am trying to register a simple spring as JMX bean through springs framework.
    How ever its throwing the following exception

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'exporter' defined in file [C:\bea91\user_projects\domains\mydomain\mbeans-wls.xml]: Initialization of bean failed; nested exception is org.springframework.jmx.export.metadata.InvalidMet adataException: No ManagedResource attribute found for class: class ConfigurableBean

    I have used commons metadata attribute style .

    Any help would be great.

    Thanks..
    Here is the code snippet for the bean

    import java.util.ArrayList;
    import java.io.Serializable;
    import java.util.Properties;

    /**
    * @@org.springframework.jmx.export.metadata.ManagedR esource
    * (description="My Managed Bean", objectName="spring:bean=testBean1",
    * log=true, logFile="jmx.log", currencyTimeLimit=15, persistPolicy="OnUpdate",
    * persistPeriod=200, persistLocation="foo", persistName="bar")
    *
    */
    public class ConfigurableMapBean implements Serializable{

    private String name;
    private String template;

    private Properties properties;



    public ConfigurableBean(){}
    public ConfigurableBean(String name, String template)
    {

    this.name=name;this.template=template;
    }

    /**
    * @@org.springframework.jmx.export.metadata.ManagedO peration
    * (description="Says Hello to all")
    */
    public String exposedOperation(String msg){return "Hello ! "+msg;}



    /**
    * @@org.springframework.jmx.export.metadata.ManagedA ttribute
    * (description="The Name Attribute", currencyTimeLimit=15)
    */
    public String getName(){return this.name;}


    /**
    * @@org.springframework.jmx.export.metadata.ManagedA ttribute
    * (description="The Template Attribute", currencyTimeLimit=20,
    * defaultValue="bar", persistPolicy="OnUpdate")
    */
    public void setName(String name){
    System.out.println("Setting new name "+name);
    this.name=name;}

    /**
    * @@org.springframework.jmx.export.metadata.ManagedA ttribute
    * (description="The Name Attribute", currencyTimeLimit=15)
    */
    public String getTemplate(){return this.template;}


    /**
    * @@org.springframework.jmx.export.metadata.ManagedA ttribute
    * (description="The Template Attribute", currencyTimeLimit=20,
    * defaultValue="bar", persistPolicy="OnUpdate")
    */
    public void setTemplate(String template){this.template=template;}


    public Properties getProperties(){return this.properties;}

    public void setProperties(Properties props){
    System.out.println("Setting new name "+name);
    this.properties=props;


    }




    /*public void init() throws Exception{

    System.out.println("Init called ");
    setName("SARA");
    setTemplate("Template1");

    cache.put("","CI", (Object)this);

    }*/

    public void destroy(){

    System.out.println("Destroy called");
    }

    }

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

    <beans>
    <!-- WLS console adapter bean -->

    <!-- WebLogic 9 MBeanServer -->
    <!--bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServer FactoryBean"/-->



    <bean id="consoleAdapter"
    class="com.interface21.wl9.jmx.mediator.Mediator">
    <property name="applicationName" value="web"/>
    </bean>
    <bean id="mbeanServer"
    class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName"
    value="java:comp/env/jmx/runtime"/>
    </bean>
    <bean id="runtimeMbeanServerConnection"
    class="org.springframework.jmx.support.MBeanServer ConnectionFactoryBean">
    <property name="serviceUrl" value="service:jmx:t3://localhost:7001/jndi/weblogic.management.mbeanservers.runtime"/>
    <property name="environment">
    <props>
    <prop key="java.naming.security.principal">weblogic</prop>
    <prop key="java.naming.security.credentials">weblogic</prop>
    <prop key="jmx.remote.protocol.provider.pkgs">
    weblogic.management.remote</prop>
    </props>
    </property>
    </bean>
    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r">
    <property name="assembler" ref="assembler"/>
    <property name="server" ref="mbeanServer"/>
    <property name="beans">
    <map>
    <entry key="bean:name=testBean1"><ref local="ConfigBean"/></entry>
    <!--entry key="bean:name=testBean2" value-ref="CustomTreeCacheMBean"/-->
    </map>
    </property>
    <property name="listeners">
    <list>
    <ref bean="consoleAdapter"/>
    </list>
    </property>

    </bean>


    <!-- Bean definition -->

    <!-- The factory bean, which contains a method createInstance -->

    <bean id="myFactoryBean" class="JBossCacheServiceImpl">
    <property name="cacheMBean" ref="CacheMBean"/>
    </bean>

    <bean id="CacheMBean" class="org.jboss.cache.TreeCache">
    </bean>


    <bean id="ConfigBean" class="ConfigurableBean">
    <property name="name" value="ss"/>
    <property name="template" value="dd"/>
    </bean>


    <bean id="BusinessCompnent" class="BusinessComponent">
    <property name="configItem"><ref bean="ConfigBean"/></property>

    </bean>


    <!--bean id="CustomTreeCacheMBean" class="org.springframework.jmx.access.MBeanProxyFa ctoryBean">
    <property name="objectName">
    <value>jboss.cache:service=CustomTreeCache</value>
    </property>
    <property name="proxyInterface">
    <value>org.jboss.cache.TreeCacheMBean</value>
    </property>
    </bean-->

    <bean id="attributeSource"
    class="org.springframework.jmx.export.metadata.Att ributesJmxAttributeSource">
    <property name="attributes">
    <bean class="org.springframework.metadata.commons.Common sAttributes"/>
    </property>
    </bean>
    <bean id="assembler" class="org.springframework.jmx.export.assembler.Me tadataMBeanInfoAssembler">
    <property name="attributeSource">
    <ref local="attributeSource"/>
    </property>
    </bean>
    </beans>

  • #2
    Make sure to compile your classes with the Commons Attributes compiler: http://jakarta.apache.org/commons/at.../compiler.html

    Comment


    • #3
      Thanks, will try that , since this was not working so in the mean time used Annotations which worked fine.

      Comment


      • #4
        I would go for annotations if possible (you can use java 5) - they don't require any compilation step, they are strong typed plus declaring them is shorter.

        Comment

        Working...
        X