For the logging of my application, I am attempting to take a MessageContext and parse the header values. An exception occurs when we try to create a list of iterators:
Iterator<SoapHeaderElement> contextHeaders = ((SoapMessage)messageContext.getRequest()).getSoapHeader().examineAllHeaderElements();
SoapHeaderElement element = (SoapHeaderElement)contextHeaders.next();
Iterator headers = ((HeaderElement1_1Impl)((DOMSource)element.getSource()).getNode()).getChildElements();
This started happening when we made the change to Spring 2.0. It results in the following error message:
java.lang.ClassCastException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.HeaderElement1_1Impl cannot be cast to com.sun.xml.messaging.saaj.soap.ver1_1.HeaderElement1_1Impl
Most of the solutions I've heard to this problem involve using the JVM -D argument at runtime. However, this worked without an argument before, so I'd like to find a solution that doesn't involve requiring changes to the java arguments in all of our spring-boot applications.
The two libraries that are fighting are saaj-impl:1.5.1 (which comes from Spring) and JDK. I'm not sure why it's trying to cast the SOAP elements to JDK.
Any help would be appreciated! Let me know if you need more details.
Switching to saaj-impl 1.3 seems to resolve the issue. I'd prefer to know why that is, but it definitely resolves it.