Create Session Bean with Vaadin 8 and Spring

Hello

I need to create a session scope BEAN in Vaadin Spring to keep my data (I know I could use the Vaadin session, but I want to try this another way)

Note, I’m using Broadcast, Push, Vaadin 8

I have tried many things, the last one is in the Configuration class:


@Configuration
@EnableAsync
@EnableCaching
public class Configuracion {
@Bean
@Scope (value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
public Ses getSes () {
return new Ses ();
}
}

Being Ses the class with my data, and then I try to read the info with


@Autowired
Configuration config;


And then config.getSes (). GetUid ()

And so much in this way as with others that I have tried gives me the following exception:

Error creating bean with name ‘scopedTarget.getSes’: Scope ‘session’ is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is 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 receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet / DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

Someone could help me? Thank you very much!!!
Ps. Sorry for my English :frowning:

Have you tried @VaadinSessionScope instead?

-Olli

GREAT!!!
WORKS!!!
Thank you… I’ve tried with Spring, in Configuration, several ways… but … KO… but with @VaadinSessionScope works perfect!!!

Thank again.
Edu

Good to hear it was helpful :slight_smile:

-Olli