@Inject stateless EJB contains data from previous request

后端 未结 1 1079
[愿得一人]
[愿得一人] 2020-12-22 12:58

I have a JAX-RS webservice with a resource for generating testdata. During tests I found out, that the injected EJB is not reinitialized and still contains data from the la

相关标签:
1条回答
  • 2020-12-22 13:26

    You have the meaning of @Stateless backwards.

    This does not mean like so:

    Hey container, here's an arbitrary class, please make it a stateless bean.

    This actually means like so:

    Hey container, here's a stateless class, you can safely use it as a stateless bean.

    You have a stateful class. You should mark it as a @Stateful bean. Otherwise, get rid of all the state (unmanaged instance variables) so you can safely use it as a @Stateless bean.

    See also:

    • Why Stateless session beans?
    • JSF request scoped bean keeps recreating new Stateful session beans on every request?
    • When using @EJB, does each managed bean get its own @EJB instance?
    0 讨论(0)
提交回复
热议问题