Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migration JAXWS application from Java 8 to Java 11

Tags:

I am looking for compatible combination of org.apache.cxf:cxf-spring-boot-starter-jaxws with jaxws-api/jaxws-ri on Java 10+.

Our application works fine on Java 8.

Also on Java 9 & 10 with --add-modules=java.se.ee.

But, when i remove this option and add following dependecies:

compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.0' compile group: 'com.sun.xml.ws', name: 'jaxws-ri', version: '2.3.0.2', ext: 'pom' compile group: 'com.sun.xml.ws', name: 'jaxws-rt', version: '2.3.0.2', ext: 'pom' 

common dependencies (with/without --add-modules in java 9/10, or java 8):

compile('org.apache.cxf:cxf-spring-boot-starter-jaxws:3.2.6') 

I become:

Caused by: java.lang.NoSuchMethodError: javax.jws.WebMethod.exclude()Z     at org.apache.cxf.jaxws.support.JaxWsServiceConfiguration.isOperation(JaxWsServiceConfiguration.java:190)     at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.isValidMethod(ReflectionServiceFactoryBean.java:1962)     at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.createInterface(ReflectionServiceFactoryBean.java:999)     at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:461)     at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:695)     at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:530)     at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)     at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)     at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)     at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)     at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)     at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460)     at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338)     at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:255)     at .....     at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)     at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.base/java.lang.reflect.Method.invoke(Method.java:564)     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)     ... 44 more 
like image 911
amjr Avatar asked Aug 17 '18 09:08

amjr


2 Answers

Note sure about sprint boot, but to get JAXWS working in Java 11, I used

<profiles>     <!-- add back the jaxws SOAP dependendies which were removed in JDK11 -->     <profile>         <id>jdk11</id>         <activation>             <jdk>[11,)</jdk>         </activation>         <!-- tested working with OpenJDK 11.0.8 -->         <dependencies>             <dependency>                 <groupId>com.sun.xml.ws</groupId>                 <artifactId>jaxws-rt</artifactId>                 <version>2.3.3</version>                 <type>pom</type>             </dependency>             <dependency>                 <groupId>com.sun.xml.ws</groupId>                 <artifactId>rt</artifactId>                 <version>2.3.3</version>             </dependency>         </dependencies>     </profile> </profiles> 
like image 137
user1791121 Avatar answered Sep 28 '22 18:09

user1791121


The documentation regarding this removal (JEP 320) has a topic called Risks and Assumptions followed by Java EE modules in which they suggest alternatives for the removals, like jaxws-ri and jaxb-ri.

In my case I was using the javax.jws package in Java 8 and it got removed in Java 11. So as the JEP suggests, I just had to add the following dependency to get it working again on Java 11:

<dependency>     <groupId>com.sun.xml.ws</groupId>     <artifactId>jaxws-ri</artifactId>     <version>2.3.2</version>     <type>pom</type> </dependency> 

In your case you may need other dependencies as well, just take a look at the JEP suggestions.

like image 40
Rafael Renan Pacheco Avatar answered Sep 28 '22 19:09

Rafael Renan Pacheco