Announcement Announcement Module
No announcement yet.
Application context duplicated Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Application context duplicated

    I have a Java SE application running a Jetty web server hosting a web application. I want to use Spring dependency injection both in the Jetty configuration and in the web application. Some beans, e.g. a dao and the entity manager, needs to be shared between the two. When I start the application I get duplicate versions of both the beans and the entity manager.

    Spring prints this to the log:
    WARN EntityManagerFactoryRegistry.addEntityManagerFactory:80 - HHH000436: Entity manager factory name (persistenceUnit) is already registered.  If entity manager will be clustered or passivated, specify a unique value for property 'hibernate.ejb.entitymanager_factory_name'
    How can I make the web application use the same application context as the rest of the application and not duplicate all the beans?

  • #2
    I fix this issue just created two application context xml files:

    1st. application-context.xml with entityManagerFactory bean. And registers in web.xml
    2nd. application-context-web.xml without entityManagerFactory bean. And registers in web.xml