Discussion:
Problems with Tomcat Session persistence - ClassNotFoundException of SecondLevelCacheSessionStore$SecondLevelCachePageMap
Joselito Lobo
2011-08-29 03:41:11 UTC
Permalink
Hello guys,

I'm running a wicket application with Tomcat 6 and I'm having problems with
Tomcat session persistence across restarts.

More specifically, apparently the session is persisted normally but just 1
minute later,
when the server is trying to deserialize the session persisted, I got the
following exception:

java.lang.ClassNotFoundException:
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
org.apache.catalina.util.CustomObjectInputStream.resolveClass(CustomObjectInputStream.java:75)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at
org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1475)
at
org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:977)
at org.apache.catalina.session.FileStore.load(FileStore.java:296)
at org.apache.catalina.session.StoreBase.processExpires(StoreBase.java:195)
at
org.apache.catalina.session.PersistentManagerBase.processExpires(PersistentManagerBase.java:563)
at
org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:685)
at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1316)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:662)


Here is the configuration of the Tomcat session persistence, I'm using
FileStore.

<Manager className='org.apache.catalina.session.PersistentManager'
saveOnRestart='true'
maxActiveSessions='-1'
minIdleSwap='0'
maxIdleSwap='60'
maxIdleBackup='0'>
<Store className='org.apache.catalina.session.FileStore'
directory='/home/tomcat/persistence' />
</Manager>


The two solutions I have found googling this I cant use:

- Disabling tomcat persistence : I can't because of my deployment
environment, tomcat under loadbalancers (pound)
- Put wicket libs in the shared-libs of Tomcat: it's not a solution


Has anyone dealed with a problem like this?

cheers,

Joselito.
Joselito Lobo
2011-08-30 00:45:40 UTC
Permalink
Hi Folks,

I found the cause of the problem.
Nothing related to Wicket session persistence.

When session persistence is configured in tomcat context.xml files
the persisted session will be deserialized in a Classloader where
the WEB-INF/lib or WEB-INF/classes are not available, only if you put the
necessary jars
in the tomcat shared-libs folder or if the instances stored in the web
session are from
java core, like the wrappers (java.lang etc).

Since Wicket makes use of web session putting in it specific classes
of the framework, which are only available at WEB-INF/lib, the
ClassNotFoundException
happens.

The solution is configure the session manager in the application specific
context.xml file.
Only like this you have the guarantee that the classes in WEB-INF/lib and
WEB-INF/classes
are available.

cheers,
Joselito.
Post by Joselito Lobo
Hello guys,
I'm running a wicket application with Tomcat 6 and I'm having problems with
Tomcat session persistence across restarts.
More specifically, apparently the session is persisted normally but just 1
minute later,
when the server is trying to deserialize the session persisted, I got the
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
org.apache.catalina.util.CustomObjectInputStream.resolveClass(CustomObjectInputStream.java:75)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at
org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1475)
at
org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:977)
at org.apache.catalina.session.FileStore.load(FileStore.java:296)
at org.apache.catalina.session.StoreBase.processExpires(StoreBase.java:195)
at
org.apache.catalina.session.PersistentManagerBase.processExpires(PersistentManagerBase.java:563)
at
org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:685)
at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1316)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:662)
Here is the configuration of the Tomcat session persistence, I'm using
FileStore.
<Manager className='org.apache.catalina.session.PersistentManager'
saveOnRestart='true'
maxActiveSessions='-1'
minIdleSwap='0'
maxIdleSwap='60'
maxIdleBackup='0'>
<Store className='org.apache.catalina.session.FileStore'
directory='/home/tomcat/persistence' />
</Manager>
- Disabling tomcat persistence : I can't because of my deployment
environment, tomcat under loadbalancers (pound)
- Put wicket libs in the shared-libs of Tomcat: it's not a solution
Has anyone dealed with a problem like this?
cheers,
Joselito.
Martin Grigorov
2011-08-30 07:07:13 UTC
Permalink
Thanks for the update, Joselito!
Post by Joselito Lobo
Hi Folks,
I found the cause of the problem.
Nothing related to Wicket session persistence.
When session persistence is configured in tomcat context.xml files
the persisted session will be deserialized in a Classloader where
the WEB-INF/lib or WEB-INF/classes are not available, only if you put the
necessary jars
in the tomcat shared-libs folder or if the instances stored in the web
session are from
java core, like the wrappers (java.lang etc).
Since Wicket makes use of  web session putting in it specific classes
of the framework, which are only available at WEB-INF/lib, the
ClassNotFoundException
happens.
The solution is configure the session manager in the application specific
context.xml file.
Only like this you have the guarantee that the classes in WEB-INF/lib and
WEB-INF/classes
are available.
cheers,
Joselito.
Post by Joselito Lobo
Hello guys,
I'm running a wicket application with Tomcat 6 and I'm having problems with
Tomcat session persistence across restarts.
More specifically, apparently the session is persisted normally but just 1
minute later,
when the server is trying to deserialize the session persisted, I got the
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap
 at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
 at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
 at
org.apache.catalina.util.CustomObjectInputStream.resolveClass(CustomObjectInputStream.java:75)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
 at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
 at
org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1475)
at
org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:977)
 at org.apache.catalina.session.FileStore.load(FileStore.java:296)
at org.apache.catalina.session.StoreBase.processExpires(StoreBase.java:195)
 at
org.apache.catalina.session.PersistentManagerBase.processExpires(PersistentManagerBase.java:563)
at
org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:685)
 at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1316)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
 at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
 at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:662)
Here is the configuration of the Tomcat session persistence, I'm using
FileStore.
<Manager className='org.apache.catalina.session.PersistentManager'
saveOnRestart='true'
maxActiveSessions='-1'
minIdleSwap='0'
maxIdleSwap='60'
maxIdleBackup='0'>
<Store className='org.apache.catalina.session.FileStore'
directory='/home/tomcat/persistence' />
</Manager>
- Disabling tomcat persistence  :   I can't because of my deployment
environment, tomcat under loadbalancers (pound)
- Put wicket libs in the shared-libs of Tomcat: it's not a solution
Has anyone dealed with a problem like this?
cheers,
Joselito.
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Loading...