Hi,

Try changing your Person class so that it implements Serializable.

Regards,
Simon

-----Original Message-----
From: Sreelakshmi Dokkara [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 19, 2006 10:26 AM
To: jcs-users@jakarta.apache.org
Subject: Problem getting JCS to work

Hi Aaron,
I'm getting the CacheException while trying to cache an object. 
Here's the piece of code I've been working with.

import org.apache.jcs.JCS;
import org.apache.jcs.access.exception.CacheException;

public class Main {

        /**
         * @param args
         */
        public static void main(String[] args) {
 
                Person mary_ = new Person("MARY");
 
                  //Create an instance of the Cache Hnadler
              JCS cache = null;
              try{
                  cache = JCS.getInstance("testCache1");
                  if(null == cache)
                  {System.out.println("cache= null");}

                  //Insert the objects into the cache
                  if(null == mary_)
                  {
                          System.out.println("the object is null");
                  }
                  System.out.println("b4 put"); 
                  String key = mary_.toString();
                  System.out.println(key);
                  cache.put(key, mary_);
                  System.out.println("after put");
              }
              catch(CacheException CE)
              {
                  System.out.println("caught exception "+
CE.getCause());
              }
              if(null != cache)
              {
                  cache.get(mary_.toString()); 
              }
        }

}
class Person
{
        private String name;
        Person(String str)
        {
                name = str;
        }
 
        public String toString()
        {
                return name;
        }
}

My configuration file is as follows:
(no new lines this time)

# DEFAULT CACHE REGION 
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribut
es
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory
.lru.LRUMemoryCache

# PRE-DEFINED CACHE REGIONS 
jcs.region.testCache1=DC
jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCac
heAttributes
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.eng
ine.memory.lru.LRUMemoryCache


# AVAILABLE AUXILIARY CACHES 
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheF
actory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.Indexe
dDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=${user.dir}
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000000
jcs.auxiliary.DC.attributes.MaxKeySize=1000000
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=5000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000

And.. here's the output:
Jun 19, 2006 2:48:34 PM 
org.apache.jcs.engine.control.CompositeCacheManager configure
INFO: Creating cache manager from config file: /cache.ccf
Jun 19, 2006 2:48:34 PM
org.apache.jcs.utils.threadpool.ThreadPoolManager 
loadConfig
INFO: thread_pool.default PoolConfiguration = useBoundary = 
[true]boundarySize = [2000]maximumPoolSize = [150]minimumPoolSize = 
[4]keepAliveTime = [300000]whenBlockedPolicy = [RUN]startUpSize = [4]
Jun 19, 2006 2:48:34 PM 
org.apache.jcs.engine.control.CompositeCacheConfigurator 
setDefaultAuxValues
INFO: Setting default auxiliaries to DC
Jun 19, 2006 2:48:34 PM 
org.apache.jcs.engine.control.CompositeCacheConfigurator 
setDefaultCompositeCacheAttributes
INFO: setting defaultCompositeCacheAttributes to [ useLateral = true, 
useRemote = true, useDisk = true, maxObjs = 1000, maxSpoolPerRun = -1 ]
Jun 19, 2006 2:48:34 PM 
org.apache.jcs.engine.control.CompositeCacheConfigurator 
parseElementAttributes
INFO: No special ElementAttribute class defined for key 
[jcs.default.elementattributes], using default class.
Jun 19, 2006 2:48:34 PM 
org.apache.jcs.engine.control.CompositeCacheConfigurator 
setDefaultElementAttributes
INFO: setting defaultElementAttributes to [ IS_LATERAL = true, IS_SPOOL
= 
true, IS_REMOTE = true, IS_ETERNAL = true, MaxLifeSeconds = -1, IdleTime
= 
-1, CreateTime = 1150708714948, LastAccessTime = 1150708714948, 
getTimeToLiveSeconds() = -1, createTime = 1150708714948 ]
Jun 19, 2006 2:48:34 PM 
org.apache.jcs.engine.control.CompositeCacheConfigurator 
parseElementAttributes
INFO: No special ElementAttribute class defined for key 
[jcs.region.testCache1.elementattributes], using default class.
Jun 19, 2006 2:48:34 PM org.apache.jcs.engine.memory.lru.LRUMemoryCache 
initialize
INFO: initialized LRUMemoryCache for testCache1
Jun 19, 2006 2:48:34 PM org.apache.jcs.engine.control.CompositeCache 
<init>
INFO: Constructed cache with name: testCache1
Jun 19, 2006 2:48:35 PM 
org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache <init>
INFO: Cache file root directory: C:\EclipseForJava\JCSLab
Jun 19, 2006 2:48:35 PM 
org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache initKeyMap
INFO: Set maxKeySize to: '1000000'
Jun 19, 2006 2:48:35 PM 
org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache initRecycleBin
INFO: Set recycle max Size to MaxRecycleBinSize: '5000'
Jun 19, 2006 2:48:35 PM 
org.apache.jcs.engine.control.CompositeCacheConfigurator parseRegions
INFO: Parsed regions [testCache1]
Jun 19, 2006 2:48:35 PM 
org.apache.jcs.engine.control.CompositeCacheConfigurator doConfigure
INFO: Finished configuration in 203 ms.
b4 put
MARY
caught exception null
Jun 19, 2006 2:48:35 PM 
org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache$ShutdownHook run
INFO: Disk cache was not shutdown properly.  Will try to dispose.

NOTE: The above program works fine if I cache simple strings but it
fails 
if I use objects as in the above program.

Could you help me with this please..

______________________________________________________________________

This message and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you have received this message in error please delete it and any files 
transmitted with it, after notifying [EMAIL PROTECTED] 
Any opinions expressed in this message may be those of the author and not 
necessarily those of the company. The company accepts no responsibility for the 
accuracy or completeness of any information contained herein. This message is 
not intended to create legal relations between the company and the recipient. 
Recipients should please note that messages sent via the Internet may be 
intercepted and that caution should therefore be exercised before dispatching 
to the company any confidential or sensitive information. 
Mizuho International plc Bracken House, One Friday Street, London EC4M 9JA. 
TEL. 020 72361090. Wholly owned subsidiary of Mizuho Securities Co., Ltd. 
Member of Mizuho Financial Group. Authorised and regulated by the Financial 
Services Authority. Member of the London Stock Exchange. 

Registered in England No. 1203696. Registered office as above.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to