vaadin / kubernetes-kit

Other
2 stars 2 forks source link

TargetSource is not serializable #104

Closed MichaelPluessErni closed 7 months ago

MichaelPluessErni commented 8 months ago

With the new versions of Vaadin and Spring Boot, we cannot serialize the session anymore.

Vaadin version: 24.3.3 Spring Boot version: 3.2.1 Kubernetes Kit version: 2.2.0

As far as I could track down the issue, it seems to come from an attempt of Vaadin to serialize an unserializable Spring Boot class. I suspect TargetSource to be the issue. Specifically it seems to be the TargetSource as created inside the ContextAnnotationAutowireCandidateResolver class from Spring Boot.

The error appears on every view and did not occur on older versions.

Possibly, the way NavigationListener classes are serialized may have to be adapted.

Here's the associated debug output / stacktrace:

Session serialization attempt completed in 97 ms with outcomes: [SERIALIZATION_FAILED, NOT_SERIALIZABLE_CLASSES]

NOT SERIALIZABLE CLASSES FOUND:
===============================

org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver$1
    Start Track ID: 153, Stack depth: 17. Reference stack: 
        - field (class "org.springframework.aop.framework.AdvisedSupport", name: "targetSource", type: "interface org.springframework.aop.TargetSource")
        - object (class "org.springframework.aop.framework.ProxyFactory", org.springframework.aop.framework.ProxyFactory: 0 interfaces []; 0 advisors []; targetSource [org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver$1@245eae82]; proxyTargetClass=false; optimize=false; opaque=false; exposeProxy=false; frozen=false)
        - field (class "org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor", name: "advised", type: "class org.springframework.aop.framework.AdvisedSupport")
        - object (class "org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor", org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor@6bcdc85b)
        - field (class "com.vaadin.flow.server.auth.AccessAnnotationChecker$$SpringCGLIB$$0", name: "CGLIB$CALLBACK_0", type: "interface org.springframework.cglib.proxy.MethodInterceptor")
        - object (class "com.vaadin.flow.server.auth.AccessAnnotationChecker$$SpringCGLIB$$0", com.vaadin.flow.server.auth.AccessAnnotationChecker@621453d)
        - field (class "com.vaadin.flow.server.auth.AnnotatedViewAccessChecker", name: "accessAnnotationChecker", type: "class com.vaadin.flow.server.auth.AccessAnnotationChecker")
        - object (class "com.vaadin.flow.server.auth.AnnotatedViewAccessChecker", com.vaadin.flow.server.auth.AnnotatedViewAccessChecker@3f9b8bb1)
        - custom writeObject data (class "java.util.CollSer")
        - object (class "java.util.CollSer", java.util.CollSer@4ece0290)
        - field (class "com.vaadin.flow.server.auth.NavigationAccessControl", name: "checkerList", type: "interface java.util.List")
        - object (class "com.vaadin.flow.spring.security.SpringNavigationAccessControl", com.vaadin.flow.spring.security.SpringNavigationAccessControl@33340350)
        - custom writeObject data (class "java.util.ArrayList")
        - object (class "java.util.ArrayList", [ch.coop.cosmo.ui.CosmoServiceInitListener$$Lambda$3117/0x00000007c1990000@56e25da2, com.vaadin.flow.spring.security.SpringNavigationAccessControl@33340350, com.vaadin.flow.spring.scopes.VaadinRouteScope$NavigationListener@5e66ba6a])
        - element of array (index: 0)
        - array (class "[Ljava.lang.Object;", size: 2)
        - field (class "java.lang.invoke.SerializedLambda", name: "capturedArgs", type: "class [Ljava.lang.Object;")
        - object (class "java.lang.invoke.SerializedLambda", SerializedLambda[capturingClass=class com.vaadin.flow.component.internal.UIInternals, functionalInterfaceMethod=com/vaadin/flow/shared/Registration.remove:()V, implementation=invokeStatic com/vaadin/flow/component/internal/UIInternals.lambda$addListener$3630f8ab$1:(Ljava/util/List;Ljava/lang/Object;)V, instantiatedMethodType=()V, numCaptured=2])
        - field (class "com.vaadin.flow.spring.scopes.VaadinRouteScope$NavigationListener", name: "beforeEnterListener", type: "interface com.vaadin.flow.shared.Registration")
        - object (class "com.vaadin.flow.spring.scopes.VaadinRouteScope$NavigationListener", com.vaadin.flow.spring.scopes.VaadinRouteScope$NavigationListener@5e66ba6a)
        - custom writeObject data (class "java.util.HashMap")
        - object (class "java.util.HashMap", {com.vaadin.flow.spring.scopes.VaadinRouteScope$NavigationListener=com.vaadin.flow.spring.scopes.VaadinRouteScope$NavigationListener@5e66ba6a})
        - field (class "com.vaadin.flow.server.Attributes", name: "attributes", type: "class java.util.HashMap")
        - object (class "com.vaadin.flow.server.Attributes", com.vaadin.flow.server.Attributes@3f06f0e7)
        - field (class "com.vaadin.flow.component.Component", name: "attributes", type: "class com.vaadin.flow.server.Attributes")
        - object (class "com.vaadin.flow.component.UI", com.vaadin.flow.component.UI@4a8d232b)
        - custom writeObject data (class "java.util.HashMap")
        - object (class "java.util.HashMap", {1=com.vaadin.flow.component.UI@4a8d232b})
        - custom writeObject data (class "com.vaadin.flow.server.VaadinSession")
        - object (class "com.vaadin.flow.spring.SpringVaadinSession", com.vaadin.flow.spring.SpringVaadinSession@3b926880)
        - custom writeObject data (class "java.util.HashMap")
        - root object (class "java.util.HashMap", {com.vaadin.flow.server.VaadinSession.springServlet=com.vaadin.flow.spring.SpringVaadinSession@3b926880, springServlet.lock=java.util.concurrent.locks.ReentrantLock@187fbbf1[Unlocked], org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository.CSRF_TOKEN=org.springframework.security.web.csrf.DefaultCsrfToken@553670bf, clusterKey=d15d4510-623e-4a06-9ea8-ac081a28cf1b_SOURCE:4525E6596B8A2A0F9435E4FE2E3E9EC7})
    End Track ID: 153
mcollovati commented 8 months ago

Probably the same issue as https://github.com/vaadin/flow/issues/18458

mcollovati commented 7 months ago

@heruan The issue has been fixed in Flow, so probably this one could also be closed.