7

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'
G. Miller
  • 79
  • 1
  • 6
  • 5
    [Does this Answer](https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j) helps? – gtgaxiola Aug 01 '18 at 17:55
  • Just a note: The artifact _javax.xml.ws : jaxws-api : 2.3.0_ was released before Java 9 came out, which makes it more likely to not be updated for the module system. – Nicolai Parlog Aug 01 '18 at 19:00
  • @gtgaxiola we are using glassfish libraries for jaxb, that seems to be OK, the issue is with the jaxws library. – G. Miller Aug 02 '18 at 14:43
  • @Nicolai we have also tried the newer **jboss-jaxws-api_2.3_spec** library and that throws the same NPE. – G. Miller Aug 02 '18 at 14:44
  • 1
    By *what's that line of code*, I meant the application code block and not the JDK line of code actually. Anyway, can still not figure out a way to reproduce what you're facing. – Naman Aug 02 '18 at 14:57
  • 1
    @feelingunwelcome I am using the library suggested in the other post and am getting a compilation error (please see my edit). This was my initial question (_With most suggested libraries, compilation fails with the following missing packages_). Could you please unmark this as duplicate since the duplicate posts do not contain an answer to this specific problem? – G. Miller Aug 02 '18 at 18:04
  • I was also not able to use the solutions provided in the referenced questions. Still the same error. I vote for reopening. – Honza Zidek Sep 19 '18 at 14:09

0 Answers0