jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Gallagher <ni...@switchfire.com>
Subject Re: ClassCastException for non-wrapper Object Keys
Date Mon, 12 Jun 2006 13:09:24 GMT
Hi Pooja,

This might still be a classpath issue. It is possible that the JCS jar
file was loaded by a different classloader to the one your client
application was loaded by. If this is the case, JCS will ask its
classloader to load any class definitions it needs, and the JCS
classloader might not know where your application class files were
loaded from.

The reverse would be true - your client application might not have
problems accessing JCS class files, if JCS' classloader was a parent of
your application classloader. In general, if one classloader loads
another classloader, the second classloader can access classes loaded by
its parent, but the parent cannot access classes loaded by its children.

If your client application runs in an application server, try packaging
the JCS jar file directly into the WAR/EAR file you deploy, and remove
it from any server-side 'lib' folder.

This could of course just be a bug :)


On Mon, 2006-06-12 at 18:01 +0530, Pooja 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)

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message