title: Entity manager being regisered second time (WARN: HHH000436: Entity manager factory name (empsys) is already registered.)
body: <p>There is a similar question but the accepted solution did not apply (Issue caused somehow by Spring MVC, which is not the case as it is in this similar question: <a href="https://stackoverflow.com/questions/10866263/spring-3-1-hibernate-4-1-jpa-entity-manager-factory-is-registered-twice">Spring 3.1 + Hibernate 4.1 JPA, Entity manager factory is registered twice</a>)</p>
  
  <p>To be clear my only issue is the warning that the entity manager factory's(emf) name has been registered twice, I don't have any issues using JPA despite the warning.</p>
  
  <p>So how is the emf name being loaded the first time if spring is not doing it, and should/how_do I stop it?</p>
  
  <p><strong>Environment</strong>: Glassfish v 3.1.1, Spring 3.1.1, JPA 2.0 (Hibernate-entity-manager 4.1.0), Struts2</p>
  
  <p>I am getting the following warning:</p>
  
  <pre><code>WARN: HHH000436: Entity manager factory name (empsys) is already registered.  If entity manager will be clustered or passivated, specify a unique value for property 'hibernate.ejb.entitymanager_factory_name'
  </code></pre>
  
  <p>Here is part of the <strong>server log</strong> (last line is the warning, I chopped off the top but rest is continuous):</p>
  
  <pre><code>INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
  INFO: HHH000412: Hibernate Core {4.1.0.Final}
  INFO: HHH000206: hibernate.properties not found
  INFO: HHH000021: Bytecode provider name : javassist
  INFO: HHH000204: Processing PersistenceUnitInfo [
      name: empsys
      ...]
  INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
  INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
  INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
  INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
  INFO: HHH000397: Using ASTQueryTranslatorFactory
  INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  INFO: PWC1412: WebModule[null] ServletContext.log():No Spring WebApplicationInitializer types detected on classpath
  INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring root WebApplicationContext
  INFO: Root WebApplicationContext: initialization started
  INFO: Refreshing Root WebApplicationContext: startup date [Sat Sep 01 19:14:15 MDT 2012]; root of context hierarchy
  INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
  INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
  INFO: JSR-330 'javax.inject.Named' annotation found and supported for component scanning
  INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
  INFO: Bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#3170938b' of type [class org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  INFO: Bean 'dataSource' of type [class org.springframework.jndi.JndiObjectFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  INFO: Bean 'dataSource' of type [class com.sun.gjc.spi.jdbc40.DataSource40] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  INFO: Building JPA container EntityManagerFactory for persistence unit 'empsys'
  INFO: HHH000204: Processing PersistenceUnitInfo [
      name: empsys
      ...]
  INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
  INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
  INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
  INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
  INFO: HHH000397: Using ASTQueryTranslatorFactory
  INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  WARN: HHH000436: Entity manager factory name (empsys) is already registered.  If entity manager will be clustered or passivated, specify a unique value for property 'hibernate.ejb.entitymanager_factory_name'
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;struts2&lt;/filter-name&gt;
          &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;struts2&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath:applicationContext.xml&lt;/param-value&gt;
      &lt;/context-param&gt;  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;/index.action&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:p="http://www.springframework.org/schema/p"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:jdbc="http://www.springframework.org/schema/jdbc"
         xmlns:jee="http://www.springframework.org/schema/jee"
         xsi:schemaLocation="
              http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/aop
              http://www.springframework.org/schema/aop/spring-aop.xsd
              http://www.springframework.org/schema/tx
              http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
              http://www.springframework.org/schema/jdbc
              http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-3.0.xsd
              http://www.springframework.org/schema/jee 
              http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"&gt;
      &lt;context:annotation-config/&gt;            
      &lt;context:component-scan base-package="com.kenmcwilliams.employmentsystem" /&gt;
      &lt;jee:jndi-lookup id="dataSource" jndi-name="jdbc/empsys" /&gt; 
      &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/&gt;
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;!--  &lt;property name="persistenceUnitName" value="empsys" /&gt; --&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/&gt;
          &lt;/property&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
  
      &lt;/bean&gt;
      &lt;bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/&gt;
      &lt;tx:annotation-driven  transaction-manager="transactionManager"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>persistence.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
    &lt;persistence-unit name="empsys" transaction-type="JTA"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;jta-data-source&gt;jdbc/empsys&lt;/jta-data-source&gt;
      &lt;class&gt;com.quaternion.orm.Something&lt;/class&gt;
      &lt;properties&gt;
        &lt;property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/&gt; 
        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>