Issue
I have a java application that serves Soap xml web services, in the present case it is java8 app and running on weblogic 12c. I decided to upgrade it java11 and also weblogic 14c. As far as I read from Oracle's documentations Oracle removed jaxws and jaxb from JDK11 permanently.Based on a few articles I've read, all I have to do in pom.xml before migration;
- Set java version => 11
- Set maven-compiler-plugin version min => 3.8.0
- Put jaxws and jaxb dependencies explicitly
I have done those things and I have added dependencies like
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.1</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-jxc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.7.6</version>
</dependency>
I have removed old jaxb implementation and added MOXY implementation. Every thing is fine until deployment to the wls 14c, a successfully compilation, I can see the jars in my war file;
- jaxb-api-2.3.1.jar
- jaxws-api-2.3.1.jar
- jaxws-rt-2.3.1.jar
- eclipselink-2.7.6.jar
When I try to deploy war file to wls 14c, I get weird stack trace error on wsl 14c console logs;
weblogic.application.ModuleException: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/sun/xml/ws/db/glassfish/JAXBRIContextFactory.getContext(Ljavax/xml/bind/Marshaller;)Lcom/sun/xml/ws/spi/db/BindingContext; @8: invokevirtual
Reason:
Type 'com/sun/xml/bind/v2/runtime/JAXBContextImpl' (current frame, stack[1]) is not assignable to 'javax/xml/bind/JAXBContext'
Current Frame:
bci: @8
flags: { }
locals: { 'com/sun/xml/ws/db/glassfish/JAXBRIContextFactory', 'javax/xml/bind/Marshaller' }
stack: { 'com/sun/xml/ws/db/glassfish/JAXBRIContextFactory', 'com/sun/xml/bind/v2/runtime/JAXBContextImpl' }
Bytecode:
0000000: 2a2b c000 34b6 0035 b600 36b0
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
I couldn't understand the error message, what am I missing ? Could you please help.
Solution
I found the solution, if you are running your app on wls14c, the only thing you have to do is adddin JAX-RT dependency with provided scope. Because in java11, jax-ws and jaxb are removed but not in wls14c.
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
Answered By - turkuaz07
Answer Checked By - Terry (JavaFixing Volunteer)