Generated code from wsimport fails to compile in Java 10.0.2. We have tried various libraries (including the ones mentioned here).
With most suggested libraries, compilation fails with the following missing packages:
error: package javax.xml.ws is not visible
error: package javax.jws is not visible
We can get past the compilation errors using the following libararies:
compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.0'
compile group: 'javax.jws.jsr181-api', name: 'jsr181-api', version: '2.1.1'
We are also including the following jaxb libraries:
compile group: 'org.glassfish.jaxb', name: 'jaxb-core', version: '2.3.0.1'
compile group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.0.1'
However this fails at runtime with NullPointerException.
Here is the code from Service.java:
protected Service(java.net.URL wsdlDocumentLocation, QName serviceName) {
delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation, // line 112
serviceName,
this.getClass());
}
This is called from the generated code for the web service:
public IMOTPWS(URL wsdlLocation) {
super(wsdlLocation, IMOTPWS_QNAME);
}
Here is the stack track from a sample repro:
java.lang.NullPointerException
at javax.xml.ws.Service.<init>(Service.java:112)
at com.automationrhapsody.reststub.resources.IMOTPWS.<init>(IMOTPWS.java:47)
at com.automationrhapsody.reststub.RestStubApp.createImoSoapClient(RestStubApp.java:34)
at com.automationrhapsody.reststub.RestStubApp.run(RestStubApp.java:28)
at com.automationrhapsody.reststub.RestStubApp.run(RestStubApp.java:13)
at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:87)
at io.dropwizard.cli.Cli.run(Cli.java:78)
at io.dropwizard.Application.run(Application.java:93)
at com.automationrhapsody.reststub.RestStubApp.main(RestStubApp.java:16)
There is one other (newer) library other than javax.xml.ws:jaxws-api that would compile:
compile group: 'org.jboss.spec.javax.xml.ws', name: 'jboss-jaxws-api_2.3_spec', version: '1.0.0.Final'
However, this produces the same NullPointerException.
This is code that was working fine under Java 8.
We are looking for a solution that does not involve --add-modules, since the JDK modules are removed in Java 11 we will have to revisit this next month with Java 11. The answers marked as duplicate either involve adding the JDK modules, or suggest libraries that do not resolve the issue.
EDIT
Adding the recommended jaxws library to build.gradle as follows (as recommended here) gives the compilation error "package javax.xml.ws is not visible". So perhaps my question is really just about adding this library? What have I done wrong or what step have I missed?
compile group: 'com.sun.xml.ws', name: 'jaxws-ri', version: '2.3.0.2', ext: 'pom'