roc230 / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Error: spymemcached in Grails #146

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi.
I'm trying to insert the following in memcached:
----------------------------------
public class ProductVO implements java.io.Serializable (
    public Integer id;
    public String name;
    public String description;
)
----------------------------------

memcachedClient = new MemcachedClient (AddrUtil.getAddresses ("localhost: 
11212"))
def products = Product.findAll (). collect (
                  new ProductVO (
                                   id: it.id,
                                   name: it.name,
                                   description: it.description
                  )). ToArray (new ProductVO [0]))

memcachedClient.set ("products_key", products)
Ok.
log:
----------------
<31 set products_key 1 3600 488
> 31 STORED
-------------------

But if I try to apply to this key, I get Exception:
 def lb = get ("products_key")
<31 get products_key
> 31 sending key last_businesses
> 31 END
------------------------------------
2010-07-02 13:35:02.865 WARN 
net.spy.memcached.transcoders.SerializingTranscoder:  Caught CNFE decoding 488 
bytes of data
java.lang.ClassNotFoundException: com.mysite.app.vo.ProductVO
    at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:128)
    at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass(GrailsRootLoader.java:43)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at net.spy.memcached.transcoders.BaseSerializingTranscoder.deserialize(BaseSerializingTranscoder.java:100)
    at net.spy.memcached.transcoders.SerializingTranscoder.decode(SerializingTranscoder.java:66)
    at net.spy.memcached.transcoders.TranscodeService$1.call(TranscodeService.java:36)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at net.spy.memcached.transcoders.TranscodeService$Task.run(TranscodeService.java:83)
    at net.spy.memcached.transcoders.TranscodeService$Task.get(TranscodeService.java:69)
    at net.spy.memcached.internal.GetFuture.get(GetFuture.java:38)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:917)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:939)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at com.geogamma.services.BusinessGatewayService.get(BusinessGatewayService.groovy:35)
    at com.geogamma.services.BusinessGatewayService$get.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)

Thx.

Original issue reported on code.google.com by Alexande...@gmail.com on 4 Jul 2010 at 12:04

GoogleCodeExporter commented 9 years ago
Having been in a similar situation recently (although not with Groovy), I can 
say this is a class loading problem and not a spymemcached issue.

The thing to check is that the serialized class and the spy memcached library 
are part of the same class loader. In my case, just to illustrate an example, I 
was seeing the CNFE because my memcached jar was in tomcat/common/lib, while my 
serialized class was part of my webapp (app/WEB-INF/classes). This causes the 
CNFE because the memcached library doesn't "see" the webapp's class that was 
cached. Moving the library from common/lib to app/WEB-INF/lib takes care of 
this.

Original comment by morales....@gmail.com on 4 Apr 2011 at 1:23

GoogleCodeExporter commented 9 years ago
Thanks It worked for me.

Original comment by pankajav...@gmail.com on 28 Apr 2011 at 2:12

GoogleCodeExporter commented 9 years ago
This appears to be an issue on the user side. Closing the issue for now. If 
this is still an issue please reopen the bug.

Original comment by mikewie...@gmail.com on 17 Aug 2012 at 5:51

GoogleCodeExporter commented 9 years ago
If you're in the cloud with a service provider like Heroku where you can't 
simply change the jar placement in app server directories ... the tip given 
here is more effective as a workaround: 
http://code.google.com/p/spymemcached/issues/detail?id=155#c2

Original comment by pulkitsi...@gmail.com on 5 Feb 2013 at 10:01