Skip to main content

How to turn off session attribute serialization?

6 replies [Last post]
sl5337
Offline
Joined: 2008-09-26
Points: 0

I am using Glassfish v2 ur2 with NetBeans 6.1. Each time I redeploy an application Glassfish throws Exceptions indicating that it cannot serialize the objects that I have placed in session. These objects don't implement the Serializable interface so from that standpoint I understand why the Exceptions are being thrown. What I can't figure out is how to configure Glassfish such that it does not try to serialize the objects in session. The documentation indicates that the default persistence type is 'memory'. I haven't overridden that property in either the domain.xml or sun-web.xml for my Web application so I don't understand why Glassfish is trying to persist these objects. Any pointers here would be greatly appreciated. Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jluehe
Offline
Joined: 2004-12-01
Points: 0

During a redeploy, all sessions are destroyed (and not serialized), unless you explicitly request that all active sessions be preserved during the redeploy, by specifying "keepSessions=true", as follows:

asadmin redeploy --properties keepSessions=true

in which case the sessions are serialized, and the serialized representations stored in memory for the duration of the redeploy.

Notice that the "keepSessions" redeploy property was added only recently, so I doubt you are using it.

Are you perhaps talking about a server restart?

In this case, all active sessions are serialized and written to file (even if the session persistence type is "memory"), and restored following the restart.

See

http://blogs.sun.com/jluehe/entry/how_to_disable_persisting_of

for how to disable this behaviour.

Thanks!

Ludovic Champenois

glassfish@javadesktop.org wrote:
> During a redeploy, all sessions are destroyed (and not serialized), unless you explicitly request that all active sessions be preserved during the redeploy, by specifying "keepSessions=true", as follows:
>
> asadmin redeploy --properties keepSessions=true
>
>
But this works only for recent GF V3 prelude builds, not GlassFish V2
UR2, right?

Lufo
> in which case the sessions are serialized, and the serialized representations stored in memory for the duration of the redeploy.
>
> Notice that the "keepSessions" redeploy property was added only recently, so I doubt you are using it.
>
> Are you perhaps talking about a server restart?
>
> In this case, all active sessions are serialized and written to file (even if the session persistence type is "memory"), and restored following the restart.
>
> See
>
> http://blogs.sun.com/jluehe/entry/how_to_disable_persisting_of
>
> for how to disable this behaviour.
>
> Thanks!
> [Message sent by forum member 'jluehe' (jluehe)]
>
> http://forums.java.net/jive/thread.jspa?messageID=302364
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Jan Luehe

On 09/29/08 08:58 AM, Ludovic Champenois wrote:
> glassfish@javadesktop.org wrote:
>> During a redeploy, all sessions are destroyed (and not serialized),
>> unless you explicitly request that all active sessions be preserved
>> during the redeploy, by specifying "keepSessions=true", as follows:
>>
>> asadmin redeploy --properties keepSessions=true
>>
>>
> But this works only for recent GF V3 prelude builds, not GlassFish V2
> UR2, right?

Yes, I just realized the initial report mentioned GlassFish V2 UR2,
which does not provide the
above option.

Notice that I also mentioned the following:

> Notice that the "keepSessions" redeploy property was added only
recently, so I doubt you are using it.
.
to avoid any confusion. :)

Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

sl5337
Offline
Joined: 2008-09-26
Points: 0

Thanks for the information guys. I'm definitely not restarting the server between deployments or using the 'keepSession' property. I'm using the built-in 'directory deployment' functionality of NetBeans which updates only the files that have changed and then invokes the browser passing a specified url to run the application. This seems to be a very fast way to develop and test so I'm not complaining from that standpoint, its just that it would be nice to not see the Exceptions rolling past on the monitor every time I redeploy. I've tested both closing the browser and leaving the browser open between re-deployments and I get the session persistence Exceptions either way. Here's one example:

PWC2785: Cannot serialize session attribute majorClassSelection for session 826e5da17c66f0d14eff63ae7b16
java.io.NotSerializableException: org.json.JSONObject

where I've placed an object into a session attribute named 'majorClassSelection'. I get this Exception (and several more) every time I redeploy.

Jan Luehe

On 10/ 1/08 04:40 AM, glassfish@javadesktop.org wrote:
> Thanks for the information guys. I'm definitely not restarting the server between deployments or using the 'keepSession' property. I'm using the built-in 'directory deployment' functionality of NetBeans which updates only the files that have changed and then invokes the browser passing a specified url to run the application. This seems to be a very fast way to develop and test so I'm not complaining from that standpoint, its just that it would be nice to not see the Exceptions rolling past on the monitor every time I redeploy. I've tested both closing the browser and leaving the browser open between re-deployments and I get the session persistence Exceptions either way. Here's one example:
>
> PWC2785: Cannot serialize session attribute majorClassSelection for session 826e5da17c66f0d14eff63ae7b16
> java.io.NotSerializableException: org.json.JSONObject
>
> where I've placed an object into a session attribute named 'majorClassSelection'. I get this Exception (and several more) every time I redeploy.
>

I've taken a closer look at this. During a redeploy, a webapp is first
stopped before it is destroyed. As part of being stopped, any active
sessions are serialized and saved to a file, which is then deleted as
part of the subsequent destroy operation. If a stop is followed by a
destroy, it
does not make any sense to save any sessions, and I am going to file
an enhancement request to have the saving of any active sessions suppressed
in this case. This won't be addressed in GlassFish v2.1, though, only
in GlassFish v3.

For the time being, what you can do is bundle the following
sun-web.xml with your webapp, which sets "sessionFilename"
to the empty string:








This will suppress serialization and saving of any active sessions
when your webapp is stopped (as part of a redeploy or server restart).

Let me know if this works for you.

Thanks!

Jan

> [Message sent by forum member 'sl5337' (sl5337)]
>
> http://forums.java.net/jive/thread.jspa?messageID=302681
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

jluehe
Offline
Joined: 2004-12-01
Points: 0