sessionjava-ee-7wildfly-8stateful-session-bean

javaee statefull bean not working


I've defined an @Stateful @StatefulTimeout(value = 2, unit = TimeUnit.HOURS) rest bean so that it can hold a private MyContext userContext; (basically a List<String> holding all previous values passed to the rest bean).

I've launched my webapp in a wildfly 8.1 container on openshift.

Unfortunatly my bean is not working properly.

It seems that the bean is re-created on each call as if the container was unable to relates two calls to the same session. This seems to be confirmed by the fact that there is no cookie nor session id param on the client side.

What could be missing in my app / conf ? Why isn't wildfly automatically creating a user session ?


Edit : sample code : https://github.com/GrmpCerber/testStatefulRest


Solution

  • Looking at your code sample, it seems you are missing a @SessionScoped annotation, as explained in this answer.