I have application, which uses Spring, Hibernate and Spring Security. My goal is to have one config (.xml) file for each of these frameworks and load them only once. So basically I want spring-config.xml, hibernate-config.xml, spring-security.xml and web.xml as configuration files. It works now as I want, BUT as I look at deployment logs, there are obviously duplicate entries – beans that are loaded more than one time.
web.xml – http://pastebin.com/7ELvV8fS
spring-config.xml – http://pastebin.com/FVTcNu7L
hibernate-config.xml – http://pastebin.com/xXWbgAex
spring-security.xml – http://pastebin.com/JUycGUNA
GlassFish 3.1 deployment output – http://pastebin.com/53Bgyj2r
As you can see in output, there are few times that spring-config.xml is initiated. Also my custom bean in spring-config.xml is initiated two times.
This is happening because you are loading the spring-config again in Spring-security via
you could try removing this . By the configuation below, you need not specify a separate context param for spring-security.