I was using classpath*: resource for Spring application context loading. All context definition files are in the
/WEB-INF/classes/appCtx
directory and its subdirectories.
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:appCtx/**/*.xml</param-value> </context-param>
However, when I enabled Spring Security in my web application, I got the exception:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Duplicate <http> element detected|Offending resource: ServletContext resource [/WEB-INF/classes/appCtx/applicationContext-security.xml]
The solution is pretty simple – move the security context configuration (e.g. applicationContext-security.xml) to a different directory outside appCtx
and load it directly:
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:appCtx/**/*.xml /WEB-INF/applicationContext-security.xml </param-value> </context-param>