Reputation: 2584
I have a Spring bean with scope session. This bean holds a reference to another singleton bean which is not serializable. What is the best approach if I want to serialize the session scoped bean?
The same question is already asked here: Spring session-scoped beans (controllers) and references to services, in terms of serialization
The accepted answer is that:
[...]this issue is resolved in spring 3.0 by providing a proxy of non-serializable beans, which obtains an instance from the current application context
As far as I understand the speaker in the linked video it should "just work". But in my case it doesn't! When I try to serialize my session scoped bean i get a NotSerializableException
.
How can I solve this problem?
Upvotes: 2
Views: 5747
Reputation: 3775
You may mark singleton reference field as transient
. Then check How to execute method after deserialization and load reference from ApplicationContext
.
Also, please provide stacktrace.
P.S.
It is not too good idea to use session passivation.
Upvotes: -1