Error java.lang.NoClassDefFoundError: javax/jws/WebService in Java 11

4.3k views Asked by At

In my cxf webservice invocation while I set the JaxWsProxyFactoryBean service class, I get a fatal error whose trace I have given below. I am migrating my code from java 8 to java 11.

I have set all the required library jars,cxf bundle and jax-ws jars at my build path but still I am unable to resolve the error. Here is my code:

        APIWS _stub = null;
        JaxWsProxyFactoryBean fac = new JaxWsProxyFactoryBean();
        
        fac.setAddress(API_WS_URL);
        fac.setServiceClass(APIWS.class);

        _stub = (APIWS) fac.create();
        Client c = ClientProxy.getClient(_stub);
        HTTPConduit http = (HTTPConduit)c.getConduit();
        HTTPClientPolicy policy = new HTTPClientPolicy();
        policy.setConnectionTimeout(0);
        policy.setReceiveTimeout(0);
        http.setClient(policy);

        c.getInInterceptors().add(new LoggingInInterceptor());
        c.getInInterceptors().add(new LoggingOutInterceptor());
        ApiWS.aboutCall(_stub);
        List<String> output = ApiWS.invokeLiqApiWebService(_stub, transformedQueue);
        outputFileList.addAll(output);

Error:

java.lang.NoClassDefFoundError: javax/jws/WebService
at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.initialize(JaxWsImplementorInfo.java:273)
at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.<init>(JaxWsImplementorInfo.java:60)
at org.apache.cxf.jaxws.JaxWsClientFactoryBean.setServiceClass(JaxWsClientFactoryBean.java:43)
at org.apache.cxf.frontend.ClientProxyFactoryBean.setServiceClass(ClientProxyFactoryBean.java:224)
at com.qnb.ib.loaniq.inbound.interfaces.process.LIQProcess.callLiqAPI(LIQProcess.java:331)
at com.qnb.ib.loaniq.inbound.interfaces.process.LIQProcess.process(LIQProcess.java:154)
at com.qnb.ib.loaniq.inbound.interfaces.process.LIQJobManager.processJob(LIQJobManager.java:106)
at com.qnb.ib.loaniq.inbound.interfaces.process.LIQJobManager.main(LIQJobManager.java:132)
Caused by: java.lang.ClassNotFoundException: javax.jws.WebService
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 8 more

Need help resolving this issue.

Thanks

1

There are 1 answers

3
Sourav Roy On

These are the jars I have added in my build path to resolve the issue with calling the Web Services.

  • FastInfoset-1.2.15.jar
  • gmbal-api-only-3.1.0-b001.jar -ha-api-3.1.9.jar
  • istack-commons-runtime-3.0.7.jar
  • javax.activation-1.2.0.jar
  • javax.activation-api-1.2.0.jar
  • javax.annotation-api-1.3.2.jar
  • javax.jws-api-1.1.jar
  • javax.xml.soap-api-1.4.0.jar
  • jaxb-api-2.3.1.jar
  • jaxb-runtime-2.3.1.jar
  • jaxws-api-2.3.1.jar
  • jaxws-ri-2.3.1.pom
  • jaxws-rt-2.3.1.jar
  • management-api-3.0.0-b012.jar
  • mimepull-1.9.10.jar
  • policy-2.7.5.jar
  • saaj-impl-1.5.0.jar stax2-api-4.1.jar
  • stax-ex-1.8.jar
  • streambuffer-1.5.6.jar -txw2-2.3.1.jar
  • woodstox-core-5.1.0.jar

Hope this helps those who are facing similar issue in java 11