Vaadin scopes problems

In my application I need to use spring beans.

I annotated my bean with @VaadinSessionScope or @UIScope and I get the following error :

Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
	at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(
	at axioma.rubik.engine.vaadin.contesto.ConnessioniSession.getSessionId(
	at axioma.rubik.contesto.Connessioni.init(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(

Anotating it with @Scope(“session”) I get a different error (Session is not active).

What’s wrong ?


Where you are autowiring the @VaadinSessionScope bean? It should be a @Route or @Scope(“prototype”) bound to a @Route. I do not get this exception on my test application. I suspect that you are trying to autowire to a non-request context.

I’m autowiring in another bean as usual with Spring.
The bean is in the request context.
The Spring integration with Vaadin 8 was straightforeward : normal Spring bean integration.
With Vaadin 14 is not clear, for me, where and how beans can be found.
If I create @Scope(“session”) bean they do not work at all.
Retriving bean from the context often fails.
I still don’t understand if @Route are beans or not.
I’m confused and documentation doesn’t clarify dependency between Spring and Vaadin.
Tks for any help.