Your keys and values must be serializable. Although the JCS api suggests that you can cache any object, you must only cache serializable objects. This is a known issue with no good solution.
--- Pooja <[EMAIL PROTECTED]> wrote: > Hi > > I've configured my cache using the default values > from apache site. The > cache is being configured, I confirmed cuz it gets > the name I speicifed in > cache.ccf. > > Now, if I try to put a Long, String or other wrapper > objects as keys, > everything works fine. But the moment I supply my > own object as key, I get > CacheException (with no further cause or explanation > below it) - Exception > trace attached at the end. > > Also, from the empty cache if I try to get an object > (I expect null) with my > key, I get a ClassCastException! - Again, if I try > to get using Long, String > etc, it returns null all right. > > The custom object which I am using as key contained > a long field and an enum > field. I changed it to long and int as an > experiment, but the result was the > same. Is there some place I need to also tell the > cache about the type of > the keys I'll be storing? Is enum a problem? I > gathered from the site and > from the signature of put() and get() that it can be > any Object. > > I am hoping there is some simple explanation for > this behavior which I don't > know. Will be glad for any light. > > PS: Classpath is not a problem, I confirmed by > instantiating a key object > above the get and it happens all right. > > Thanks > --- Pooja. > Exception Trace for CacheException while putting my > own object as key: > org.apache.jcs.access.exception.CacheException: > com.anduril.ring.promos.PromotionKey > org.apache.jcs.access.exception.CacheException: > com.anduril.ring.promos.PromotionKey > at > org.apache.jcs.access.CacheAccess.put(CacheAccess.java:300) > at > org.apache.jcs.access.CacheAccess.put(CacheAccess.java:266) > ..... no further causes given > +++++++++++++++++++++++++++++ > Exception Trace for ClassCastException while getting > with my own object as > key: > java.lang.ClassCastException: > com.anduril.ring.promos.PromotionKey > at > org.apache.jcs.access.CacheAccess.get(CacheAccess.java:201) > at > com.anduril.ring.promocache.PromoCacheJCS.getPromoMessage(Unknown > Source) > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]