JDK 11 with JAXB and JAXWS problems

2019-07-28 09:21发布

问题:

My goal is to migrate a Web Services application that currently works with Java 8 to Java 11. Because the JAXB and JAX-WS components have been removed from JDK11, it is necessary to add the appropriate libraries, either using Maven or Jar libraries.

There is a wide variety of recommendations and suggestions from others who have encountered similar issues, but I am not able to find a combination that does not have errors.

pom.xml

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11.0.2</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>11.0.2</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.0</version>
</dependency>
<!-- JAXWS for Java 11 -->
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>rt</artifactId>
    <version>2.3.1</version>
</dependency>

modules-info.java

module org.openfx.gustfx {
    requires javafx.controls;
    requires javafx.fxml;
    requires transitive javafx.graphics;
    requires java.xml.bind;
    requires java.xml.ws;
    requires javax.jws;

    opens com.agile.ws.schema.common.v1.jaxws to javafx.fxml;
    opens org.openfx.gustfx to javafx.fxml;
    exports org.openfx.gustfx;
}

Running the code produces this error:

Unable to make field protected java.lang.String  
 com.agile.ws.schema.common.v1.jaxws.AgileUserUserGroupIdentifierType.classIdentifier accessible: module org.openfx.gustfx does not "opens com.agile.ws.schema.common.v1.jaxws" to unnamed module @4860d8d7

How could I find this unnamed module ?

回答1:

I was able to solve this problem by adding

opens com.agile.ws.schema.common.v1.jaxws;
opens com.agile.ws.schema.project.v1.jaxws;
opens com.agile.ws.schema.search.v1.jaxws;
opens com.agile.ws.schema.collaboration.v1.jaxws;

to the module-info.java. The error message suggested that the 'opens' should be to a specific module but apparently this is not required