PDA

View Full Version : Tomcat Persistent Session


alanhay
Jul 17th, 2007, 05:35 AM
I'm having trouble with persistent sessions in Tomcat when using Session scoped objects.

The exception is:

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.springframework.aop.scope.DefaultScopedObject

The contents of the session at the time of the reload are as below.

USER_AUTHENTICATED_KEY :: USER_AUTHENTICATED_KEY :: class java.lang.String
scopedTarget.navigation :: com.barrhibb.ifa.framework.web.tag.NavigationImpl@ e69619 :: class com.barrhibb.ifa.framework.web.tag.NavigationImpl
scopedTarget.systemUser :: com.barrhibb.ifa.framework.auth.SystemUser@8869b9 :: class com.barrhibb.ifa.framework.auth.SystemUser
scopedTarget.capitaInitialState :: com.barrhibb.ifa.service.CapitaInitialStateImpl@1d 5264c :: class com.barrhibb.ifa.service.CapitaInitialStateImpl
scopedTarget.ifaCommandBean :: com.barrhibb.ifa.web.command.IfaCommandBeanImpl@19 7e57c :: class com.barrhibb.ifa.web.command.IfaCommandBeanImpl

Can I use a DefaultScopedObject somehow that implements Serializable or is there another solution to this problem?

Thanks.

Jörg Heinicke
Jul 17th, 2007, 07:28 PM
Can I use a DefaultScopedObject somehow that implements Serializable or is there another solution to this problem?

The problem is the actual proxy. I have no idea how to make it Serializable (both CGLib and JDK dynamic proxy). I had this issue as well in different constellations and always could work around it. So the question is why you put the proxy into the session.

Jörg

jdamasceno
Jul 27th, 2007, 02:22 PM
I have this same problem. I need to access a session scoped bean in a jsp page so i put it in httpsession.

How you solved?

Jörg Heinicke
Jul 29th, 2007, 01:15 AM
There are actually two different ways I have used so far to work around this issue. You have to decide which is more appropriate in your case.

The first one is to scope the proxy to ScopedObject (http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/aop/scope/ScopedObject.html#getTargetObject()) and retrieve the actual object by getTargetObject(). The second one is to use lookup method injection (http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-factory-lookup-method-injection) and so to refrain from proxy at all.

Joerg