jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <minf...@sharp.fm>
Subject Re: Really stupid question - can I cache any random object?
Date Wed, 09 Jul 2008 09:22:55 GMT
Bret Schuhmacher wrote:

> Can I cache *any* object?  I get exceptions when I attempt to cache
> objects I've created, although I can cache simple objects like Strings.
> Unfortunately cache.put(String foo, myCustomObject bar) doesn't tell me
> much more than the name of the class I'm trying to cache (i.e.
> "myCustomObject").  It doesn't tell me why it threw the exception, it
> just prints a stacktrace.  Like I said - it all works fine if I do this:
> cache.put("foo", "bar"), but if I do cache.put("foo", new
> myCustomObject()) it will fail.  I've even cast myCustomObject back to
> Object, but it still doesn't like it.  Any way to get more verbose
> messages out of the JCS code instead of just ERROR level?

I suspect that at the very least your custom object would need to be 
serializable before it could be cacheable. Does your object implement 
the Serializable interface?

I suspect the method signatures in JCS should say they only accept 
Serializable, rather than Object, though I haven't looked at the code to 
be sure.


View raw message