Langali
Langali

Reputation: 3207

Session Clustering a Grails app in Tomcat

Has any one done it yet? I am having class loader problems de-serializing the grails session object.

Here is the error:

WARN net.spy.memcached.transcoders.SerializingTranscoder: Caught CNFE decoding 1168 bytes of data [exec] java.lang.ClassNotFoundException: com.myapp.User [exec] at org.codehaus.groovy.tools.RootLoader.findClass (RootLoader.java:156) [exec] at java.lang.ClassLoader.loadClass(ClassLoader.java:319) [exec] at org.codehaus.groovy.tools.RootLoader.loadClass (RootLoader.java:128) [exec] at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass (GrailsRootLoader.java:43) [exec] at java.lang.ClassLoader.loadClass(ClassLoader.java:254) [exec] at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:402) [exec] at java.lang.Class.forName0(Native Method) [exec] at java.lang.Class.forName(Class.java:247) [exec] at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java:604) [exec] at java.io.ObjectInputStream.readNonProxyDesc (ObjectInputStream.java:1575) [exec] at java.io.ObjectInputStream.readClassDesc (ObjectInputStream.java:1496) [exec] at java.io.ObjectInputStream.readOrdinaryObject (ObjectInputStream.java:1732) [exec] at java.io.ObjectInputStream.readObject0 (ObjectInputStream.java:1329) [exec] at java.io.ObjectInputStream.readObject (ObjectInputStream.java:351) [exec] at net.spy.memcached.transcoders.BaseSerializingTranscoder.deserialize (BaseSerializingTranscoder.java:100) [exec] at net.spy.memcached.transcoders.SerializingTranscoder.decode (SerializingTranscoder.java:66)

Upvotes: 2

Views: 1336

Answers (3)

hongtium
hongtium

Reputation: 465

I've the same CNFE problem while using SpyMemcached in development environment. The CNFE(ClassNotFoundException) of SpyMemcached, is mainly generated by the multi ClassLoader in a JVM. Search this article: http://code.google.com/p/spymemcached/issues/detail?id=155 , find:

"I had this issue in the past and I found a solution. The occurs because the memcached client it is loaded using a classloader and the serialized object class is loaded using another classloader. "

So, in my case, I just move the memcached-VERSION.jar from ext-lib dir to app-lib dir(/WEB-INF/lib). Then the memcached client and the app classes are all in the same ClassLoader, and this exception is cleared.

Upvotes: 0

leebutts
leebutts

Reputation: 4882

I've only ever used sticky sessions via an apache mod_proxy setup so have never tried sharing session data across nodes. Is that an option for you?

Upvotes: 0

Siegfried Puchbauer
Siegfried Puchbauer

Reputation: 6539

I guess there is no easy way to fix it since Grails is using a custom classloader to load the domain classes (I assume the com.myapp.User class is a domain class). As a workaround you could store just store the id of the user in the session and use a technique like I've described here to retrieve it on every request. This would also provide the benefit of reducing the size of the session that needs to be replicated.

Upvotes: 1

Related Questions