I got this issue these days, when I'm migrating spring-security-saml-extensions-1-x to spring-security-saml2-service-provider which depends on opensaml 3.4.6. At first, I thought it's caused by re-initialize opensaml somehow, from the documentation, it says it
Any class that uses both Spring Security and OpenSAML should statically initialize OpenSamlInitializationService at the beginning of the class.
But no matter I remove the line or not
static {
OpenSamlInitializationService.initialize();
}
The issue still happens. The stackframes like:
java.lang.IllegalStateException: Unable to load cache item
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:572)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:419)
at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:137)
......
Caused by: java.util.ServiceConfigurationError: org.opensaml.core.config.Initializer: Provider org.opensaml.xacml.config.impl.XMLObjectProviderInitializer not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
at java.util.ServiceLoader$LazyIterator.access$700(ServiceLoader.java:323)
at java.util.ServiceLoader$LazyIterator$2.run(ServiceLoader.java:407)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:409)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.opensaml.core.config.InitializationService.initialize(InitializationService.java:53)
at org.springframework.security.saml2.core.OpenSamlInitializationService.initialize(OpenSamlInitializationService.java:122)
at org.springframework.security.saml2.core.OpenSamlInitializationService.initialize(OpenSamlInitializationService.java:97)
at com.mytestsvr.api.config.SecurityConfig.<clinit>(SecurityConfig.java:284)
......
I think it's loaded twice since there's a cache item in the stack, but I don't have such opensaml in webapp folder except this one. Any suggestion for resolving such issue? Thanks in advance.