O
O
Oleg Yakovenko2013-01-11 16:48:54
Java
Oleg Yakovenko, 2013-01-11 16:48:54

Question about @Stateless beans?

Good day.
Sat debugged his framework application and stumbled upon the following problem.
There is a code:

@Stateless
@LocalBean
public class BasicDAO implements Serializable, IBasicDao {

  private static final long serialVersionUID = 4102542574230571583L;
  @PersistenceContext
  protected EntityManager em;
...

Actually stateless wrapper entity manager.
There are @SessionScoped and @ViewScoped beans into which I inject this DAO.
While debugging, I noticed such a thing that on different computers, for different users, this object is the same. This would seem to be normal behavior, but even on long-term operations with the base, the object is the same, although according to the docs, if the resource is already participating in the transaction, then with a parallel call, I should receive a new instance of the object from the container. Is this a jboss as 7 bug? or did I do something wrong? It's just that earlier in the project, we also encountered the fact that the stateless bean was rummaged between all users, and therefore Ajax did not work normally for us, because when two users started working, one could see the data of the other.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mayorovp, 2013-01-12
@mayorovp

Do you even know how Stateless is translated?
If you're having trouble mixing data from different users, then your bean is not de facto stateless.

1
1nd1go, 2013-01-11
@1nd1go

What docs say that? In general, the statelace bean, as far as I remember from the spec, is taken from the pool. It's possible that your jboss is configured with an initial amount of 1, and the dev environment is no longer created.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question