title: package javax.xml.ws is not visible (Java 10)
body: <p>Generated code from wsimport fails to compile in Java 10.0.2. We have tried various libraries (including the ones mentioned <a href="https://stackoverflow.com/a/48204154/9052733">here</a>).</p>
  
  <p>With most suggested libraries, compilation fails with the following missing packages:</p>
  
  <pre><code>error: package javax.xml.ws is not visible
  error: package javax.jws is not visible
  </code></pre>
  
  <p>We can get past the compilation errors using the following libararies:</p>
  
  <pre><code>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'
  </code></pre>
  
  <p>We are also including the following jaxb libraries:</p>
  
  <pre><code>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'
  </code></pre>
  
  <p>However this fails at runtime with NullPointerException.</p>
  
  <p>Here is the code from Service.java:</p>
  
  <pre><code>protected Service(java.net.URL wsdlDocumentLocation, QName serviceName) {
      delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation, // line 112
              serviceName,
              this.getClass());
  }
  </code></pre>
  
  <p>This is called from the generated code for the web service:</p>
  
  <pre><code>public IMOTPWS(URL wsdlLocation) {
      super(wsdlLocation, IMOTPWS_QNAME);
  }
  </code></pre>
  
  <p>Here is the stack track from a sample repro:</p>
  
  <pre><code>java.lang.NullPointerException
          at javax.xml.ws.Service.&lt;init&gt;(Service.java:112)
          at com.automationrhapsody.reststub.resources.IMOTPWS.&lt;init&gt;(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)
  </code></pre>
  
  <p>There is one other (newer) library other than javax.xml.ws:jaxws-api that would compile:</p>
  
  <pre><code>compile group: 'org.jboss.spec.javax.xml.ws', name: 'jboss-jaxws-api_2.3_spec', version: '1.0.0.Final'
  </code></pre>
  
  <p>However, this produces the same NullPointerException.</p>
  
  <p>This is code that was working fine under Java 8.</p>
  
  <p>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.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Adding the recommended jaxws library to build.gradle as follows (as recommended <a href="http://openjdk.java.net/jeps/320" rel="noreferrer">here</a>) 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?</p>
  
  <pre><code>compile group: 'com.sun.xml.ws', name: 'jaxws-ri', version: '2.3.0.2', ext: 'pom'
  </code></pre>