wang-haha / memcached-session-manager

Automatically exported from code.google.com/p/memcached-session-manager
0 stars 0 forks source link

desrialization session error with memcached (no sticky) #214

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

Bundle : liferay-portal-6.2-ce-ga2 with tomcat bundle on windows 8.1. MSM 14.4 
on ubuntu
LIB on tomcat\lib: memcached-session-manager-1.8.2.jar, 
memcached-session-manager-tc7-1.8.2.jar, spymemcached-2.11.1.jar

I use memcached to persist liferay session and i have error to deserialize 
session. I add a non sticky config with standard serialization/ desrialization 
in the context.xml of Tomcat 7 (see below) :

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:192.168.56.101:11126"
sticky="false"
lockingMode="auto"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
sessionBackupAsync="false"
sessionBackupTimeout="2000"
/>

For each action in my Liferay portal (navigation to other portlet) i lost the 
session and  i have the following stack trace.

Can someone help me to resolve this problem.

Thank's in advance.

PRÉCIS: Trying to store session in memcached: 
7C46D6FC47BB4587ABE7C973E30E9DCC-n1
oct. 16, 2014 10:16:25 AM 
net.spy.memcached.transcoders.BaseSerializingTranscoder compress
PRÉCIS: Compressed 231856 bytes to 28632
oct. 16, 2014 10:16:25 AM net.spy.memcached.transcoders.SerializingTranscoder 
encode
PRÉCIS: Compressed [B from 231856 to 28632
oct. 16, 2014 10:16:25 AM de.javakaffee.web.msm.BackupSessionTask call
PRÉCIS: Finished for session id 7C46D6FC47BB4587ABE7C973E30E9DCC-n1, returning 
status SUCCESS
oct. 16, 2014 10:16:25 AM de.javakaffee.web.msm.BackupSessionTask releaseLock
PRÉCIS: Releasing lock for session 7C46D6FC47BB4587ABE7C973E30E9DCC-n1
oct. 16, 2014 10:16:33 AM de.javakaffee.web.msm.MemcachedSessionService 
loadFromMemcached
PRÉCIS: Loading session from memcached: 7C46D6FC47BB4587ABE7C973E30E9DCC-n1
oct. 16, 2014 10:18:38 AM de.javakaffee.web.msm.MemcachedSessionService 
loadFromMemcached
AVERTISSEMENT: Could not deserialize session with id 
7C46D6FC47BB4587ABE7C973E30E9DCC-n1 from memcached, session will be purged from 
storage.
de.javakaffee.web.msm.TranscoderDeserializationException: Caught IOException 
decoding data
at 
de.javakaffee.web.msm.JavaSerializationTranscoder.deserializeAttributes(JavaSeri
alizationTranscoder.java:188)
at 
de.javakaffee.web.msm.TranscoderService.deserializeAttributes(TranscoderService.
java:171)
at 
de.javakaffee.web.msm.TranscoderService.deserialize(TranscoderService.java:128)
at 
de.javakaffee.web.msm.MemcachedSessionService.loadFromMemcached(MemcachedSession
Service.java:1100)
at 
de.javakaffee.web.msm.MemcachedSessionService.findSession(MemcachedSessionServic
e.java:585)
at 
de.javakaffee.web.msm.MemcachedBackupSessionManager.findSession(MemcachedBackupS
essionManager.java:216)
at org.apache.catalina.connector.Request.doGetSession(Request.java:2865)
at org.apache.catalina.connector.Request.getSession(Request.java:2316)
at 
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:898)
at 
com.liferay.portal.kernel.servlet.SanitizedServletResponse.setXXSSProtection(San
itizedServletResponse.java:167)
at 
com.liferay.portal.kernel.servlet.SanitizedServletResponse.getSanitizedServletRe
sponse(SanitizedServletResponse.java:81)
at 
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.secureResponseHe
aders(InvokerFilter.java:275)
at 
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(Invoker
Filter.java:81)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilt
erChain.java:243)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.
java:210)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:2
22)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:1
23)
at 
de.javakaffee.web.msm.RequestTrackingContextValve.invoke(RequestTrackingContextV
alve.java:99)
at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.jav
a:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:156)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at 
de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.j
ava:124)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118
)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at 
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor
.java:1023)
at 
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractPro
tocol.java:589)
at 
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.StreamCorruptedException: invalid type code: 00
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1379)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at java.util.HashSet.readObject(HashSet.java:333)
at sun.reflect.GeneratedMethodAccessor686.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.skipCustomData(ObjectInputStream.java:1959)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1921)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at java.util.ArrayList.readObject(ArrayList.java:776)
at sun.reflect.GeneratedMethodAccessor684.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at 
de.javakaffee.web.msm.JavaSerializationTranscoder.deserializeAttributes(JavaSeri
alizationTranscoder.java:172)
... 44 more

I check the implementation of each object of the 18 attributes of the session  
manager and  i found nothing surprising. Each attribute is serializable.

1- PREVIOUS_LAYOUT = com.liferay.portal.model.impl.LayoutImpl
2- PORTLET_RENDER_PARAMETERS_ = HashMap
3- j_password = String, 
4- DEVICE = com.liferay.portal.kernel.util.TransientValue, 
5- USER_ID = Long, 
6- org.apache.struts.action.LOCALE = Locale,
7- USER = com.liferay.portal.model.impl.UserImpl,
8- com.liferay.portal.servlet.PortalSessionActivationListener = 
com.liferay.portal.kernel.util.TransientValue
9- LIFERAY_SHARED_VISITED_GROUP_ID_PREVIOUS = Long,
10- LIFERAY_SHARED_AUTHENTICATION_TOKEN10175_LAYOUT_2 = String,
11- LIFERAY_SHARED_VISITED_GROUP_ID_RECENT = Long,
12- USER_UUID = String,
13- LAST_PATH= com.liferay.portal.kernel.struts.LastPath
14-LIFERAY_SHARED_AUTHENTICATION_TOKEN#CSRF= String,
15- j_username= String,
16- LIFERAY_SHARED_AUTHENTICATION_TOKEN43277_LAYOUT_49 = String,
17- HTTPS_INITIAL = Boolean,
18-com.liferay.portal.servlet.filters.secure.SecureFilter_AUTHENTICATED_USER = 
String

Original issue reported on code.google.com by sofiane....@serli.com on 21 Oct 2014 at 9:11

GoogleCodeExporter commented 8 years ago
I see the "java.io.StreamCorruptedException: invalid type code: 00" - perhaps 
there's an issue with memcached? To be honest, I have no clue what could be the 
issue on the side of msm. 

Original comment by martin.grotzke on 21 Oct 2014 at 12:56

GoogleCodeExporter commented 8 years ago
Hi Martin,

Thank's for your quick reponse. I change the serialization strategy, i use now 
kyro

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
    memcachedNodes="n1:192.168.56.101:11126"
    sticky="false"
    lockingMode="auto"
    requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
    sessionBackupAsync="false"
    sessionBackupTimeout="2000"
    transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
    />

Now, I get  a nother Exception described in the following stack trace :

AVERTISSEMENT: Could not deserialize session with id 
BDC4DBBDF7F906A315F7A53CF38CEF43-n1 from memcached, session will be purged from 
storage.
de.javakaffee.web.msm.TranscoderDeserializationException: 
com.esotericsoftware.kryo.SerializationException: Unable to deserialize object 
of type: java.util.concurrent.ConcurrentHashMap
    at de.javakaffee.web.msm.serializer.kryo.KryoTranscoder.deserializeAttributes(KryoTranscoder.java:291)
    at de.javakaffee.web.msm.TranscoderService.deserializeAttributes(TranscoderService.java:171)
    at de.javakaffee.web.msm.TranscoderService.deserialize(TranscoderService.java:128)
    at de.javakaffee.web.msm.MemcachedSessionService.loadFromMemcached(MemcachedSessionService.java:1100)
    at de.javakaffee.web.msm.MemcachedSessionService.findSession(MemcachedSessionService.java:585)
    at de.javakaffee.web.msm.MemcachedBackupSessionManager.findSession(MemcachedBackupSessionManager.java:216)
    at org.apache.catalina.connector.Request.doGetSession(Request.java:2865)
    at org.apache.catalina.connector.Request.getSession(Request.java:2316)
    at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:898)
    at com.liferay.portal.kernel.servlet.SanitizedServletResponse.setXXSSProtection(SanitizedServletResponse.java:167)
    at com.liferay.portal.kernel.servlet.SanitizedServletResponse.getSanitizedServletResponse(SanitizedServletResponse.java:81)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.secureResponseHeaders(InvokerFilter.java:275)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:81)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at de.javakaffee.web.msm.RequestTrackingContextValve.invoke(RequestTrackingContextValve.java:99)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:156)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:124)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.esotericsoftware.kryo.SerializationException: Unable to 
deserialize object of type: java.util.concurrent.ConcurrentHashMap
    at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:593)
    at com.esotericsoftware.kryo.ObjectBuffer.readObject(ObjectBuffer.java:213)
    at de.javakaffee.web.msm.serializer.kryo.KryoTranscoder.deserializeAttributes(KryoTranscoder.java:289)
    ... 40 more
Caused by: com.esotericsoftware.kryo.SerializationException: Unable to find 
class: com.liferay.portal.model.impl.LayoutImpl
    at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:449)
    at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:561)
    at com.esotericsoftware.kryo.serialize.MapSerializer.readObjectData(MapSerializer.java:129)
    at com.esotericsoftware.kryo.Serializer.readObject(Serializer.java:61)
    at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:589)
    ... 42 more
Caused by: java.lang.ClassNotFoundException: 
com.liferay.portal.model.impl.LayoutImpl
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:340)
    at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:447)
    ... 46 more

Can you help to resolve this issue, i attached the log file of tomcat liferay.

Thank's in advance.

Original comment by sofiane....@serli.com on 21 Oct 2014 at 1:27

GoogleCodeExporter commented 8 years ago
According to the "java.lang.ClassNotFoundException: 
com.liferay.portal.model.impl.LayoutImpl" it seems that there's a classloader 
issue. Kryo should be loaded by the same classloader as your app and liferay, 
typically this would be web-inf/lib, but I'm not sure how it should look like 
for liferay. 

Original comment by martin.grotzke on 21 Oct 2014 at 6:49