geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fredrik Jonson <>
Subject Re: EntityManager & Servlets
Date Tue, 15 Sep 2009 19:18:48 GMT
Jay D. McHugh wrote:

>  Geronimo should not allow you to add container managed entity
>  managers to servlets. They would not be thread safe.

Then please examine the example again. You're correct that there's a
stateless bean acting as a accessor in _part_ of the example. But
there is also a servlet class called Test - search for in
that page.

You'll see that the servlet Test has a injected EntityManager. Now, I
didn't notice before but the servlet actually only accesses the entity
manager in a UserTransaction which it looks up per request. I'm not
sure if and how the transaction would make access to the single
instance entity manager thread safe though?

The blog linked below seems to suggest that even when using user
transactions - which on the other side seems very servlet injection
friendly - it is still wrong to share a entity manager instance in

Fredrik Jonson

View raw message