PDA

View Full Version : Persist JMX MBean


greenbean
Feb 19th, 2006, 01:12 PM
I setup the java 5 annotations to expose my mbean. I also set the persist values. However, I don't see persistence occuring. I do see the bean exposed. I am using Jboss 4.0.3SP1 with Spring 1.2.6.

Should this work? I tried the JBoss method of using a jboss service mbean and it works, however, I would like to avoid the configurations and just use annotations from spring if possible.

@ManagedResource(objectName = "jmx:bean=TestBean",
description = "Test bean",
log = true,
logFile = "jmx.log",
currencyTimeLimit = 0,
persistPolicy = "OnUpdate",
persistName = "testBean")

@ManagedAttribute(description = "Get the value",
currencyTimeLimit = 0,
defaultValue = "test",
persistPolicy = "OnUpdate")
public String getValue() {
return value;
}

@ManagedAttribute(description = "Set the value",
currencyTimeLimit = 0,
defaultValue = "test",
persistPolicy = "OnUpdate")
public void setValue(String value) {
this.value = value;
}

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="assembler" ref="assembler" />
<property name="autodetect" value="true" />
<property name="namingStrategy" ref="namingStrategy"/>
</bean>

<bean id="attributeSource" class="org.springframework.jmx.export.annotation.Annotati onJmxAttributeSource" />
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNami ngStrategy">
<property name="attributeSource" ref="attributeSource" />
</bean>
<bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataM BeanInfoAssembler">
<property name="attributeSource" ref="attributeSource" />
</bean>

Costin Leau
Feb 20th, 2006, 04:51 AM
Spring JMX support handles the publishing and creating of your mbean - it's just a tool and not a jmx implementation per-se - it's up to the jmx implementation to add support for persistence (which is optional). If the jmx implementation you have in jboss (jbossmx I assume) handles this then it should work no matter if you are using spring jmx or plain jmx.

grafpoo
Mar 20th, 2006, 02:22 PM
'should' is the word. my admittedly limited testing produces the same result. the bean is exposed in the jmx-console, changes are applied, but they are not persisted. same app server, by the way - jboss 4.0.3sp1, with spring 1.2.8

i'll keep twiddling...

grafpoo
Mar 20th, 2006, 02:23 PM
spring 1.2.6 i mean...

Costin Leau
Mar 20th, 2006, 02:31 PM
Spring 1.2.8 - you mean head or is it just a typo?

P.S. you replied at the same time as I did. I just saw your post now.

grafpoo
Mar 20th, 2006, 02:42 PM
it's worse than that - i was thinking of struts 1.2.8. sigh

by the way, i tested against jbossmx and the platform mbeanserver (since you stated in another post that perhaps the platform one does not support persistence). neither persisted.

jbossmx certainly does support persistence, so there seems to be a nail or a piece of duct tape missing somewhere...

grafpoo
Mar 20th, 2006, 03:20 PM
one more and i'll shut up .... for a while ....

could be this:
http://wiki.jboss.org/wiki/Wiki.jsp?page=WhyMyPersistentMBeanDoesNotPersistAt tributeValueChanges

seems jboss requires specification of a persistence manager

grafpoo
Mar 21st, 2006, 05:12 PM
according to an entry in jboss forums from 2001, jmx persistence is only implemented in jboss AS for their XMBean. i browsed the source to see what an XMBean does to enable persistence. it adds an entry to MBeanInfo that defines the persistence-manager. i tried that for my test spring-based mbean, but still no persistence, so there is something else involved

Costin Leau
Mar 22nd, 2006, 02:49 AM
IIRC, in 2001 only JMX 1.0 was supported. I think there should be some JMX implementations that support persistence. have you tried Sun's JDMK(http://www.sun.com/software/jdmk/) - part of it have made it into JDK 1.5 JMX support.
You could also check the mx4j - simon is very helpful and can probably give you some advice on how to have jmx persistance in place.

aaime
Apr 24th, 2006, 05:48 AM
So, did anyone solve the spring beans over jmx persistence problem?
Any real world experience anyone can share?