[hibernate-dev] Error: registry contains more than one (2) entity manager factories: PERSISTENCE_UNIT_NAME

Scott Marlow smarlow at redhat.com
Tue Jan 8 10:01:26 EST 2013


Teresa,

I made a code change in Hibernate 4.x that impacts 
serialization/deserialization of EntityManagerFactories.  My code change 
helps Hibernate to work correctly in clustered environments (HHH-6897) 
but it looks like my change also broke your application.  In a clustered 
environment, each entity manager factory will have a unique name.

In your application, could you try setting 
"hibernate.ejb.entitymanager_factory_name" to a unique name?  Perhaps 
you could try setting it to:

  "newt" + username

Scott

On 01/08/2013 08:03 AM, Teresa Batista Neto wrote:
> Hello,
>
> I just copy/past the exception call stack from when the "registry
> contains more than one" error is thrown. The link is:
> http://pastie.org/private/cmmoyaouedgrbgpat88fxw <http://pastie.org/5647726>
>
> Thanks in advance,
> Teresa
>
>
> On Thu, Dec 20, 2012 at 3:38 PM, Scott Marlow <smarlow at redhat.com
> <mailto:smarlow at redhat.com>> wrote:
>
>     I would like to see the exception call stack from when the "registry
>     contains more than one" error is thrown.  You can copy it to a
>     website like pastie.org <http://pastie.org> or pastebin.com
>     <http://pastebin.com> and paste the link here.
>
>     Scott
>
>     On 12/20/2012 05:38 AM, Teresa Batista Neto wrote:
>
>         Dear all,
>
>         After upgrading JPA from 3.6.1 to 4.1.8 I start getting the
>         following error:
>
>         "Error: registry contains more than one (2) entity manager
>         factories:
>         PERSISTENCE_UNIT_NAME"
>
>         Below you can find a brief summary of our specification
>         requirements.
>
>         - User logins in the web application using their own oracle database
>         account.
>         - The web application only needs to access one database schema;
>         - The access rights are managed using oracle roles and grant
>         privilegies.
>         - Only one database schema and multiple user oracle accounts.
>         - We only set the username and password when users tries to
>         login in the
>         web application.
>         - The EntityManagerFactory is created using the username and
>         password of
>         the user.
>
>         - Because our web application only access one database we only
>         use one
>         persistence unit name.
>
>
>         E.g. persistence.xml
>
>         <?xml version="1.0" encoding="UTF-8"?>
>         <persistence version="1.0"
>         xmlns="http://java.sun.com/__xml/ns/persistence
>         <http://java.sun.com/xml/ns/persistence>"
>               xmlns:xsi="http://www.w3.org/__2001/XMLSchema-instance
>         <http://www.w3.org/2001/XMLSchema-instance>"
>
>           xsi:schemaLocation="http://__java.sun.com/xml/ns/__persistence
>         <http://java.sun.com/xml/ns/persistence>
>         http://java.sun.com/xml/ns/__persistence/persistence_1_0.__xsd
>         <http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd>">
>
>             <persistence-unit name="PERSISTENCE_UNIT_NAME">
>
>           <provider>org.hibernate.ejb.__HibernatePersistence</__provider>
>
>               <properties>
>               <property name="hibernate.connection.__driver_class"
>         value="oracle.jdbc.
>         OracleDriver">
>               <property name="hibernate.connection.__url"
>         value="jdbc:oracle:xx...">
>               <property name="hibernate.dialect"
>         value="org.hibernate.dialect.
>         Oracle10gDialect">
>               <property name="hibernate.default___schema"
>         value="SCHEMA_NAME">
>
>               <property name="hibernate.connection.__username"
>         value="USERNAME">
>               <property name="hibernate.connection.__password"
>         value="PASSWORD">
>
>               <property name="hibernate.connection.__autocommit"
>         value="false">
>               <property name="hbm2ddl.auto" value="validate">
>
>               <property name="hibernate.show_sql" value="true">
>               <property name="hibernate.format_sql" value="true">
>               </properties>
>             </persistence-unit>
>         </persistence>
>
>
>         E.g. how we create and close the entity manager factory
>
>         Map<String, String> configuration = new ProviderConfiguration();
>         configuration.put("hibernate.__connection.username", username);
>         configuration.put("hibernate.__connection.password", password);
>         EntityManagerFactory emf =
>         Persistence.__createEntityManagerFactory("__PERSISTENCE_UNIT_NAME",
>         configuration);
>         EntityManager em = emf.createEntityManager();
>         SptrTaxNode t = em.find(SptrTaxNode.class, 9606);
>         em.close();
>         emf.close();
>
>         Does anyone ever had a similar situation? Any ideas on how can I
>         solve this
>         problem?
>
>         Thanks in advance,
>         Teresa
>         _________________________________________________
>         hibernate-dev mailing list
>         hibernate-dev at lists.jboss.org <mailto:hibernate-dev at lists.jboss.org>
>         https://lists.jboss.org/__mailman/listinfo/hibernate-dev
>         <https://lists.jboss.org/mailman/listinfo/hibernate-dev>
>
>
>



More information about the hibernate-dev mailing list