Can't persist collection or array attributes of XMBeans
blackard Nov 4, 2005 12:35 PMWe're using JBoss 4.0.2 and JDK 1.4.2_07 on Windows and Linux boxes. Our XMBean is persisting the non-collection data using the DelegatingPersistenceManager/AttributePersistenceService/XMLAttributePersistenceManager configuration just fine. We also tested this using the ObjectStreamPersistenceManager and got the same results.
By digging into the DelegatingPersistenceManager, we were able to trace down a couple of things. First, whatever is preparing the MBeanInfo and MBeanAttributeInfo before getting to the DelegatingPersistenceManager wasn't setting the attributeValue and lastUpdatedTimeStamp2 values. By putting persistenc information on the collection attribute itself, the value and lastUpdatedTimeStamp values were being set, but attributeValue and lastUpdatedTimeStamp2 were still not being set.
Collection Set
Collection
java.util.TreeSet
I was able to get a temporary work around going on my development environment by overriding DelegatingPersistenceManager with the following change:
...
Object value = attrDesc.getFieldValue(ModelMBeanConstants.ATTRIBUTE_VALUE);
Object updated = attrDesc.getFieldValue(ModelMBeanConstants.LAST_UPDATED_TIME_STAMP2);
Object pPolicy = attrDesc.getFieldValue(ModelMBeanConstants.PERSIST_POLICY);
// Deal with persistable collections and arrays
if ( value == null && attrDesc.getFieldValue( "value" ) != null ) {
// If the value and/or lastUpdatedTimeStamp are non-null, given
// both attributeValue and lastUpdatedTimeStamp2 are null, this is
// a collection or array
value = attrDesc.getFieldValue("value");
updated = attrDesc.getFieldValue("lastUpdatedTimeStamp");
}
...
For unfathomable reasons I won't go into, the client doesn't want to recompile our own DelegatingPersistenceManager with this patch. So I created a xmbeanCollectionPersistenceSupport.jar containing our implementation. Now we're at the point that I'm stuck on.
When we put xmbeanCollectionPersistenceSupport.jar in the <JBOSS_HOME>/lib/endorsed and run the server from Eclipse using the JBoss plugin, everything works peachy and collections get persisted. However, when we run from the command line, we get this exception:
11:03:54,354 ERROR [ModelMBeanInvoker] Unable to instantiate the persistence manager:com.clientName.mx.persistence.DelegatingPersistenceManager
RuntimeErrorException: instantiating com.clientName.mx.persistence.DelegatingPersistenceManager
failed: java.lang.NoClassDefFoundError: org/jboss/mx/persistence/PersistenceManager
Cause: java.lang.NoClassDefFoundError: org/jboss/mx/persistence/PersistenceManager
How do I get my new class recognized without putting it in <JBOSS_SERVER>/lib/endorsed? Is there another way to address the issue? Can anyone put me out of my misery?
Thanks
Bob Blackard
Momentum SI