openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chintan4181 <>
Subject Multiple concurrent threads attempted to access a single broker
Date Thu, 22 Sep 2011 16:16:34 GMT
Hi, I am getting below exception 

Multiple concurrent threads attempted to access a single broker. By default
brokers are not thread safe; if you require and/or intend a broker to be
accessed by more than one thread, set the openjpa.Multithreaded property to
true to override the default behavior

We have business requirement to support multiple persistence units based on
business function. So we have created xml file and defined persistence untis
for business functions and code is getting these values and match with
persistence untis defined in persistence.xml and create Entity Managers for
those units and store into map for the usage.

//map contains list of entity managers for business functions.
private static Map&lt;String, List&lt;EntityManager&gt;> buEntityMap

//code to get the entity manager based on unit name retrieved from xml file
EntityManagerFactory factory =
entityManager = factory.createEntityManager(); 

//logic to iterate xml file,create entity managers and put into map. i have
ommited logic here.
buEntityMap.put(businessUnit, entityManagerList)

What is wrong with the code? Is it good to set openjpa.Multithreaded = true?


View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message