Trying to add security to the Spring Pet Clinic application. I do this by adding two classes: MessageSecurityWebApplicationInitizializer
and SecurityConfig
to this project and now I get this error:
Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!
Indeed in web.xml
there is mention of the ContextLoaderListener
.
MessageSecurityWebApplicationInitizializer
just extends AbstractSecurityWebApplicationInitializer
with no customization. I believe this class is what loads the additional ContextLoaderListener
but not sure how to prevent this or if doing so is desirable. I tried implementing the interface and doing what is suggested in this question:
Why this Spring application with java-based configuration don't work properly
But this did not work.
I am wondering if I am trying to mix Spring XML configuration with non-XML configuration or something. But mainly I would like to get the security to work.