[jpa-spec users] [jsr338-experts] Thread safety for injected EMs

From: Kevin Sutter <>
Date: Wed, 26 Jun 2013 11:28:46 -0500

There seems to be a lot of conflicting information on the web concerning
the thread-safety of injected EMs in runtime components. From a WebSphere
perspective, our injected EMs are thread-safe regardless of the runtime
component -- EJBs or Servlets. But, there are several references that
indicate injected EMs in a Servlet are not thread-safe [1, as an example].
 Our JPA spec is not clear on this (or, at least I couldn't find a
definitive answer). What's the consensus of the group? Should injected
EMs in a Servlet be considered thread-safe? Or, is this an implementation
detail left up to each application server?

I understand that EMs by themselves are not considered thread-safe. We're
clear on that aspect in the spec [sec 7.2]. But, when the container is
managing the injection of these EMs and the associated transactional
context, can we consider these EMs to only be accessed by a single thread?
 Like I said, WebSphere has controls and processing in place to allow for
this usage pattern, but we're not clear whether this is a generally
accepted pattern or unique to WebSphere? I think this is pretty clear
when a Transactional context is in place -- in this case, the EM should be
injectable into a Servlet. But, maybe it becomes more murky when a
Transactional context is not defined? Is this where the concern comes
from and it now depends on the QoS provided by the application server?

Customers are getting conflicting information from the specs, web
references, and jpa provider support... I'm looking for clarification on
this usage pattern. If something exists, just point me in the right
direction. Otherwise, maybe we can open a JIRA or something to clarify
this in the next rev of the spec? Thanks!


Kevin Sutter, Java EE and Java Persistence API (JPA) architect
mail:, Kevin Sutter/Rochester/IBM
phone: tl-553-3620 (office), 507-253-3620 (office)