How do I tell java 8 to use my own library instead of the internal one?
Exact problem: I had an application running on Windows 2003 (jre 1.5) Now ported to Windows 2012 server (jre 1.8). Doing this below the exception,
Caller.main: com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be added to com.sun.xml.messaging.saaj.soap.MessageImpl
The old server uses jre 1.5 , and the new server uses newer 1.8 . In jre 1.5 , we have saaj jars separately.
As of java 6, the saaj implementation is provided on its own and we don't need a separate jar for that. I am getting a class exception because of this. I want to fix this by making the classpath take saaj bans from outside and not from jre itself.
source to share
Finally I found a solution and it worked. Using the java option -Xbootclasspath we can do this.
Decision:
java -Xbootclasspath/p:.\jaxrpc16\saaj-api.jar;.\jaxrpc16\saaj-impl.jar -classpath <myClasses> <myMainClass>
Refer: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html
PS: You need to do more research to make sure this setting is safe and secure.
source to share
Well ... I had a problem in weblogic and had to change the default SAAJ implementation (the default implementation was broken!)
To achieve this in weblogic, I added this to the command line that launches weblogic:
-Djavax.xml.soap.MessageFactory=com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
So for you it should be something like this:
-Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.MessageFactoryImpl
It should work. This is how you tell the JVM to be used for the default SAAJ messages Factory.
PS: Well, to be honest, there are more ways to change this in weblogic by touching the run script and I ended up modifying the code and manually initiated the MessageFactoryImpl version that was not broken. I found that -Djavax.xml.soap.MessageFactory fixed my problem, but I was not allowed to start the production server script.
source to share