0 Replies Latest reply on Jun 12, 2007 11:07 AM by Marcel Trapman

    JBossCache, PojoCache & Serialization

    Marcel Trapman Newbie


      I have started implementing JBossCache/PojoCache and stumble to the following:

      I (basically) use the config files as provided through the samples. I also play with PojoCache 2.0. Java 1.5

      The Config files are below and I use the annotations as described.

      The issue is the following: I have an application that is very memory consuming so I try to cache the overflow of objects to disk.
      As you can see I set the cache mode to be LOCAL, cacheloader is JdbmCacheLoader is and marshallNonSerializable = true.

      1. After closing the app I expect the table to be cleared but somehow this does not happen.
      2. From what I understand my objects don't need to be serialized but when I don't do this jboss complains:

      Jun 12, 2007 4:40:42 PM org.jboss.cache.eviction.BaseEvictionAlgorithm evictCacheNode
      SEVERE: Eviction of /__JBossInternal__/9e13ccf9-0908-4234-bd1f-cf0f1deea048/1426servoy_sample_auto_pdf-1/_ID_/5c4o16-rj0vpp-f2uhehnn-1-f2uhehq1-3 failed
      java.lang.RuntimeException: java.io.NotSerializableException: com.it2be.analyzer.repository.Style
       at org.jboss.cache.CacheImpl.invokeMethod(CacheImpl.java:3860)

      3. Serializing then is not the solution either. After a while (I guess when caching to disk really takes place) I see the following error:
      Jun 12, 2007 5:01:42 PM org.jboss.cache.eviction.BaseEvictionAlgorithm evictCacheNode
      WARNING: Eviction of /e9737027-7423-45ad-b3d7-87a5f5be2174 timed out, retrying later
      and ultimately, out of the blue, I receive the next error where the class is exactly the same as the ones before:
      Jun 12, 2007 5:02:46 PM org.jboss.cache.pojo.interceptors.PojoTxInterceptor invoke
      WARNING: attach: exception occurred: java.lang.RuntimeException: java.io.InvalidClassException: com.it2be.analyzer.repository.Method; no valid constructor

      I am new to caching so I hope you forgive me my ignorance and hope you can help me to solve these issues.



      --- cluster
      <?xml version="1.0" encoding="UTF-8"?>
       <mbean code="org.jboss.cache.aop.PojoCache"
       <!-- Configure the TransactionManager -->
       <attribute name="TransactionManagerLookupClass">
       <!-- Isolation level : SERIALIZABLE
       REPEATABLE_READ (default)
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
       <!-- Valid modes are LOCAL, REPL_ASYNC and REPL_SYNC -->
       <attribute name="CacheMode">LOCAL</attribute>
       <!-- Just used for async repl: use a replication queue -->
       <attribute name="UseReplQueue">false</attribute>
       <!-- Replication interval for replication queue (in ms) -->
       <attribute name="ReplQueueInterval">0</attribute>
       <!-- Max number of elements which trigger replication -->
       <attribute name="ReplQueueMaxElements">0</attribute>
       <!-- Name of cluster. Needs to be the same for all clusters, in order
       to find each other
       <attribute name="ClusterName">Analyzer</attribute>
       <!-- Whether or not to fetch state on joining a cluster -->
       <attribute name="FetchStateOnStartup">true</attribute>
       <!-- The max amount of time (in milliseconds) we wait until the
       initial state (ie. the contents of the cache) are retrieved from
       existing members in a clustered environment
       <attribute name="InitialStateRetrievalTimeout">5000</attribute>
       <!-- Number of milliseconds to wait until all responses for a
       synchronous call have been received.
       <attribute name="SyncReplTimeout">15000</attribute>
       <!-- Max number of milliseconds to wait for a lock acquisition -->
       <attribute name="LockAcquisitionTimeout">10000</attribute>
       <!-- Name of the eviction policy class. -->
       <attribute name="EvictionPolicyClass"/>
       <attribute name="EvictionPolicyConfig">
       <attribute name="wakeUpIntervalSeconds">1</attribute>
       <!-- This defaults to 200000 if not specified -->
       <attribute name="eventQueueSize">200000</attribute>
       <!-- Name of the DEFAULT eviction policy class. -->
       <attribute name="policyClass">org.jboss.cache.eviction.LFUPolicy</attribute>
       <attribute name="timeToLiveSeconds">60</attribute>
       <!-- Cache wide default -->
       <region name="/_default_">
       <attribute name="maxNodes">10</attribute>
       <!-- New 1.3.x cache loader config block -->
       <attribute name="CacheLoaderConfig">
       <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
       <!-- we can now have multiple cache loaders, which get chained -->
       <!-- same as the old CacheLoaderConfig attribute
       location=/tmp this can be part of the properties.
       <!-- whether the cache loader writes are asynchronous -->
       <!-- only one cache loader in the chain may set fetchPersistentState to true.
       An exception is thrown if more than one cache loader sets this to true. -->
       <!-- determines whether this cache loader ignores writes - defaults to false. -->

      --- cluster pojo
      <?xml version="1.0" encoding="UTF-8"?>
       This is the PojoCache configuration file that specifies:
       1. Interceptor stack for API
       2. Annotation binding for POJO (via "prepare" element)
       Basically, this is a variant of jboss-aop.xml. Note that
       except for the customization of interceptor stack, you should
       not need to modify this file.
       To run PojoCache, you will need to define a system property:
       jboss.aop.path that contains the path to this file such that JBoss Aop
       can locate it.
       This defines the PojoCache 2.0 interceptor stack. Unless necessary, don't modify the stack here!
       <!-- Check id range validity -->
       <interceptor name="CheckId"
       <!-- Track Tx undo operation -->
       <interceptor name="Undo"
       <!-- Begining of interceptor chain -->
       <interceptor name="Start"
       <!-- Check if we need a local tx for batch processing -->
       <interceptor name="Tx"
       Mockup failed tx for testing. You will need to set PojoFailedTxMockupInterceptor.setRollback(true)
       to activate it.
       <interceptor name="MockupTx"
       <!-- Perform parent level node locking -->
       <interceptor name="TxLock"
       <!-- Interceptor to perform Pojo level rollback -->
       <interceptor name="TxUndo"
       <!-- Interceptor to used to check recursive field interception. -->
       <interceptor name="Reentrant"
       <!-- Whether to allow non-serializable pojo. Default is false. -->
       <interceptor name="MarshallNonSerializable"
       <attribute name="marshallNonSerializable">true</attribute>
       <!-- This defines the stack macro -->
       <stack name="Attach">
       <interceptor-ref name="Start"/>
       <interceptor-ref name="CheckId"/>
       <interceptor-ref name="MarshallNonSerializable"/>
       <interceptor-ref name="Tx"/>
       <!-- NOTE: You can comment this out during production although leaving it here is OK. -->
       <interceptor-ref name="MockupTx"/>
       <interceptor-ref name="TxLock"/>
       <interceptor-ref name="TxUndo"/>
       <stack name="Detach">
       <interceptor-ref name="Start"/>
       <interceptor-ref name="CheckId"/>
       <interceptor-ref name="Tx"/>
       <!-- NOTE: You can comment this out during production although leaving it here is OK. -->
       <interceptor-ref name="MockupTx"/>
       <interceptor-ref name="TxLock"/>
       <interceptor-ref name="TxUndo"/>
       <stack name="Find">
       <interceptor-ref name="Start"/>
       <interceptor-ref name="CheckId"/>
       The following section should be READ-ONLY!! It defines the annotation binding to the stack.
       <!-- This binds the jointpoint to specific in-memory operations. Currently in PojoUtil. -->
       <interceptor-ref name="Reentrant"/>
       <interceptor-ref name="Undo"/>
       pointcut="execution(* org.jboss.cache.pojo.impl.PojoCacheImpl->@org.jboss.cache.pojo.annotation.Attach(..))">
       <stack-ref name="Attach"/>
       pointcut="execution(* org.jboss.cache.pojo.impl.PojoCacheImpl->@org.jboss.cache.pojo.annotation.Detach(..))">
       <stack-ref name="Detach"/>
       pointcut="execution(* org.jboss.cache.pojo.impl.PojoCacheImpl->@org.jboss.cache.pojo.annotation.Find(..))">
       <stack-ref name="Find"/>
       Following is declaration for JDK50 annotation. You use the specific annotation on your
       POJO such that it can be instrumented. Idea is user will then need only to annotate like:
       in his POJO. There will be no need of jboss-aop.xml from user's side.
       <!-- If a POJO has PojoCachable annotation, it will be asepctized. -->
       expr="field(* $instanceof{@org.jboss.cache.pojo.annotation.Replicable}->*)"/>
       <!-- Observer and Observable to monitor field modification -->
       set(* $instanceof{@org.jboss.cache.pojo.annotation.Replicable}->*)