Problem serializing Vaadin

Hi all,

I have inherited a Vaadin application. I managed to upgrade it to the latest 7.7.x version (upgrading to 8 will come later).

Right now I’m trying to setup a HA setup, where a Vaadin application would run on multiple nodes. To do so I’d need to save the sessions to file (NFS) o to a datastore (SQL, redis, memcached, etc).

However, saving the session seems to fail. I enabled the Manager className=… in the Tomcat’s context.xml. Doing that showed me that Tomcat was unable to save/restore the sessions. I enabled -Dsun.io.serialization.extendedDebugInfo=true on the Tomcat server to see what was going on and found this:

20:55:02.612 [main]
 WARN  com.vaadin.event.ListenerMethod - Error in serialization of the application: Class com.gusi.app.backoffice.ui.UserInterface$$Lambda$79/1713903507 must implement serialization.
20:55:02.618 [main]
 WARN  o.a.c.c.C.[.[.
[/backoffice]
 - Cannot serialize session attribute [com.vaadin.server.VaadinSession.springVaadinServlet]
 for session [4A0B163025B0DE2C2929163D29589FEE]

java.io.NotSerializableException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
	- field (class "com.gusi.app.backoffice.ui.smart.SmartViewProvider", name: "applicationContext", type: "interface org.springframework.context.ApplicationContext")
	- object (class "com.gusi.app.backoffice.ui.smart.SmartViewProvider", com.gusi.app.backoffice.ui.smart.SmartViewProvider@622a3566)
	- custom writeObject data (class "java.util.LinkedList")
	- object (class "java.util.LinkedList", [com.vaadin.spring.navigator.SpringViewProvider@2b759ab1, com.gusi.app.backoffice.ui.smart.SmartViewProvider@622a3566]
)
	- field (class "com.vaadin.navigator.Navigator", name: "providers", type: "interface java.util.List")
	- object (class "com.gusi.app.backoffice.ui.smart.SmartNavigator", com.gusi.app.backoffice.ui.smart.SmartNavigator@784c3487)
	- field (class "com.vaadin.ui.UI", name: "navigator", type: "class com.vaadin.navigator.Navigator")

The UserInterface class has some Button and other Vaadin widgets that declare a click listener with a lambda function. I’ve been checking how to overcome this, but I’ve failed. Does anybody know how to serialize the user interface if it contains buttons? Or how to avoid the serialization of the interface state at all?

Best

I’ve been able to take out a few of the errors I was having, I guess I’m narrowing the problem. Right now the stacktrace is so much short, only two instances have problems serializing:

21:46:07.691 [main]
 WARN  o.a.c.c.C.[.[.
[/backoffice]
 - Cannot serialize session attribute [com.vaadin.server.VaadinSession.springVaadinServlet]
 for session [C8FA4A3F66CDFDDC870DDDC47668EE25]

java.io.NotSerializableException: com.gusi.app.backofficeservices.api.domain.UsuarioImpl
	- field (class "com.gusi.app.backoffice.security.BackofficeUserDetails", name: "usuario", type: "interface com.gusi.app.backofficeservices.api.domain.Usuario")
	- object (class "com.gusi.app.backoffice.security.BackofficeUserDetails", com.gusi.app.backoffice.security.BackofficeUserDetails@4d6025c5)
	- custom writeObject data (class "java.util.HashMap")
	- object (class "java.util.HashMap", {principal=com.gusi.app.backoffice.security.BackofficeUserDetails@4d6025c5, com.vaadin.spring.internal.UIScopeImpl$UIStore=UIStore[id=622ddfb5, sessionId=C8FA4A3F66CDFDDC870DDDC47668EE25]
})
	- field (class "com.vaadin.server.VaadinSession", name: "attributes", type: "interface java.util.Map")
	- custom writeObject data (class "com.vaadin.server.VaadinSession")
	- root object (class "com.vaadin.server.VaadinSession", com.vaadin.server.VaadinSession@37911f88)

The first one is on me. Probably it’d a matter of simply making that class and it’s child classes to implement Serializable.

The other error, regarding the com.vaadin.server.VaadinSession I’m not sure. Does it have something to do with the UsuarioImpl error?

Best,