2 Replies Latest reply on Nov 8, 2005 6:32 AM by dimitris

    Can't persist collection or array attributes of XMBeans

    blackard

      We'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

        • 1. Re: Can't persist collection or array attributes of XMBeans
          blackard

          Hmmm... didn't escape the xmbean attribute fragment... lemme try again

          &lt;attribute access="read-write" getMethod="getCustomers" setMethod="setCustomers"&gt;

          &lt;description&gt;Customer AV Set&lt;/description&gt;
          &lt;name&gt;Customers&lt;/name&gt;
          &lt;type&gt;java.util.TreeSet&lt;/type&gt;
          &lt;descriptors&gt;
          &lt;persistence persistPolicy="OnUpdate"
          persistPeriod="10"/&gt;
          &lt;currencyTimeLimit value="10"/&gt;

          &lt;/descriptors&gt;
          &lt;/attribute&gt;

          • 2. Re: Can't persist collection or array attributes of XMBeans
            dimitris

            I believe the descriptor is updated by:

            org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor

            I dont' quite understand the outcome you expect. Can you present the simplest possible testcase that reproduces the problem?