Why my persistent MBean does not persist attribute value changes?
The 1st thing to check is that you have configured your MBean to
be persistent using the XMBean deployment descriptor. The minimum
requirement is to define a persistPolicy and a persistence-manager, e.g:
<xmbean> <description>PersistentServiceExample</description> <descriptors> <persistence persistPolicy="OnUpdate"></persistence> <persistence-manager value="org.jboss.mx.persistence.DelegatingPersistenceManager"></persistence-manager> </descriptors> <class>org.jboss.jmx.examples.persistence.PersistentServiceExample</class> ...
The next thing to make sure is that you do not specify in the mbean
descriptor attribute overrides for attributes that you want to be persistent.
The reason is that, those attribute overrides take place after the
persisted values are reloaded to the MBean upon start-up, so the persisted
changes are lost. To avoid this, you should move the attribute overrides
from the mbean descriptor to the xmbean descriptor, using the <value> tag
(see HowCanIInitializeXMBeanAttributes).
The 3rd thing to check is that the persistent attribute value changes
take place through the MBeanServer, so that the persistence interceptor
can kick-in and do its job. If the MBean changes its own attributes,
or someone updates the attributes through a direct reference to the
MBean, then those changes are not persisted.
Finally, you need to make sure you are not trying to persist attributes that
cannot be persisted. For example, the XMLAttributePersistenceManager will
persist attribute types for which a PropertyEditor exists or they are
Serializable.
Referenced by:
Comments