Results 1 to 5 of 5

Thread: Unique jmx object names with Spring JMX annotations

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    107

    Question Unique jmx object names with Spring JMX annotations

    Hi,

    I have a single class that is declared as two beans with two different bean ids.

    That class has the following jmx annnotation on it.

    Code:
    @ManagedResource("foo:type=bar")
    However when I start up Spring I get:

    Code:
    Caused by: javax.management.InstanceAlreadyExistsException: foo:type=bar
    How can I get Spring to use the bean id rather than what I supply as a value to the @ManagedResource annotation?

    I've already seen the property:
    http://static.springframework.org/sp...am es(boolean)

    However this is already set to true by default and doesn't work.

    Do I need to implement my own ObjectNamingStrategy? If so would someone kindly provide an example?

    Much appreciate your help.

    Thanks.

  2. #2
    Join Date
    Jan 2007
    Posts
    107

    Default

    I tried using the key naming strategy as below.

    Code:
        <bean id="exporter" class="org.springframework.jmx.export.annotation.AnnotationMBeanExporter">
            <property name="autodetect" value="true" />
            <property name="ensureUniqueRuntimeObjectNames" value="true" />
            <property name="namingStrategy" ref="my.ObjectNamingStrategy" />
        </bean>
    
        <bean id="my.ObjectNamingStrategy" class="org.springframework.jmx.export.naming.KeyNamingStrategy">
            <property name="mappings">
                <props>
                    <prop key="myBean1">bean:name=myBean1</prop>
                    <prop key="myBean2">bean:name=myBean2</prop>
                </props>
            </property>
        </bean>
    However I now get the error:

    Code:
    Caused by: javax.management.MalformedObjectNameException: Key properties cannot be empty
    	at javax.management.ObjectName.construct(ObjectName.java:467)
    	at javax.management.ObjectName.<init>(ObjectName.java:1403)
    	at javax.management.ObjectName.getInstance(ObjectName.java:1285)
    	at org.springframework.jmx.support.ObjectNameManager.getInstance(ObjectNameManager.java:74)
    	at org.springframework.jmx.export.naming.KeyNamingStrategy.getObjectName(KeyNamingStrategy.java:140)
    	at org.springframework.jmx.export.MBeanExporter.getObjectName(MBeanExporter.java:751)
    	at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:654)
    	at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:615)
    	... 22 more

  3. #3
    Join Date
    Jan 2007
    Posts
    107

    Default

    I've now resolved this myself. Thanks.

  4. #4
    Join Date
    May 2005
    Location
    Fallbrook, CA
    Posts
    22

    Default

    How did you resolve it? I'm getting the "Key properties cannot be empty" error.

    I have a config that looks like this:
    Code:
    <bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter">
            <property name="beans">
                <map>
                    <entry key="scheduleRevision">
                        <ref bean="scheduleRevision"/>
                    </entry>
                </map>
            </property>
    </bean>

  5. #5

    Default

    How have you resolved this? please show us example. thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •