14

I have been working with JDK 9 & 10 and CXF codegen plugin 3.2.5 and 3.2.6 with no problems but, today I'm trying to update my codebase from Oracle JDK 10 to OpenJDK 11 build 28, but I'm always getting the same error:

[INFO] Error occurred during initialization of boot layer
[INFO] java.lang.module.FindException: Module java.xml.ws not found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.747 s
[INFO] Finished at: 2018-10-17T16:38:38+02:00
[INFO] Final Memory: 17M/60M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.2.6:wsdl2java (cerberus-wsdl) on project cerberus: 
[ERROR] Exit code: 1
[ERROR] Command line was: /opt/prod_jdk/bin/java --add-modules java.activation,java.xml.bind,java.xml.ws --add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.runtime=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xerces.internal.impl.xs=ALL-UNNAMED --add-exports=java.xml.bind/com.sun.xml.internal.bind.marshaller=ALL-UNNAMED --add-opens java.xml.ws/javax.xml.ws.wsaddressing=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED -jar /tmp/cxf-tmp-2828938832312113909/cxf-codegen12095310072621993552.jar /tmp/cxf-tmp-2828938832312113909/cxf-w2j12256414556760820901args

this is my pom.xml that use CXF codegen plugin:

<plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.2.6</version>
                <configuration>
                    <fork>once</fork>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>javax.annotation</groupId>
                        <artifactId>javax.annotation-api</artifactId>
                        <version>1.3.2</version>
                    </dependency>

                    <dependency>
                        <groupId>javax.activation</groupId>
                        <artifactId>javax.activation-api</artifactId>
                        <version>1.2.0</version>
                    </dependency>

                    <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.3.1</version>
                    </dependency>

                    <dependency>
                        <groupId>org.glassfish.jaxb</groupId>
                        <artifactId>jaxb-runtime</artifactId>
                        <version>2.3.1</version>
                    </dependency>

                    <dependency>
                        <groupId>javax.xml.ws</groupId>
                        <artifactId>jaxws-api</artifactId>
                        <version>2.3.1</version>
                    </dependency>

                    <dependency>
                        <groupId>com.sun.xml.ws</groupId>
                        <artifactId>jaxws-rt</artifactId>
                        <version>2.3.1</version>
                    </dependency>
                </dependencies>
<executions>...</executions>
<plugin>

Am I missing something? As far as I know this should work the same way that in JDK 9 and 10. There is an issue https://issues.apache.org/jira/browse/CXF-7741 that talk about JDK 11 compatibility, but again this is for CXF framework not for the plugin (I think).

Nico
  • 858
  • 2
  • 11
  • 27
  • 1. Your command line reads way too many arguments than your shared maven configuration part. How are you specifying those? 2. What class in your code relies on the module `java.xml.ws` precisely? – Naman Oct 17 '18 at 15:28
  • 1. The command line is generated by the plugin I guess. So maven execute the code generation in the compile goal and CXF run the command, so I don't know "nothing" about the command (correct me if I'm wrong). 2. Same that in 1 question, CXF codegen plugin use this module in order to generate the client code via WSDL. – Nico Oct 17 '18 at 15:33
  • If you really don't need any such dependency then try to remove those dependencies from within the plugin configuration and things should work normally for you. – Naman Oct 17 '18 at 16:01
  • @nullpointer the plugin surely needs `java.xml.ws`, it is a WSDL parser and JAXWS+JAXB classes code generating tool. One could imagine such a tool that does not use `java.xml.ws`, but frankly the chances are close to zero. I'd say the module is definitely needed on the classpath (or at least, would not try as a first step to remove it). – GPI Oct 17 '18 at 16:14
  • Yes sure, the module is needed by the plugin, the thing is that CXF plugin is not reading correctly the class party or something, a workaround is very welcome :) – Nico Oct 17 '18 at 19:03

2 Answers2

26

This issue will be resolved in cxf 3.3.0 (https://issues.apache.org/jira/browse/CXF-7852)

For now, you can run mvn install in the mvn-plugins directory of https://github.com/apache/cxf to build the plugins, and set version in pom to 3.3.0-SNAPSHOT

Edit: Plugin is in the apache snapshots repo, so probably better to get it from there:

<pluginRepositories>         
   <pluginRepository>
      <id>apache.snapshots</id>
      <name>Maven Plugin Snapshots</name>
      <url>http://repository.apache.org/snapshots/</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
</pluginRepositories>
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-codegen-plugin</artifactId>
      <version>3.3.0-SNAPSHOT</version>
...

Note (2019-01-28): The plugin is now released, we can add the dependency as usual:

<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>3.3.0</version>
  <type>maven-plugin</type>
</dependency>
JuanMoreno
  • 2,498
  • 1
  • 25
  • 34
Initial-B
  • 276
  • 3
  • 3
  • For complex builds where somebody mostly needs java 8, the toolchains plugin should be used to enforce the usage of java 10 for the cxf-codegen-plugin to work. – razvanone Oct 26 '18 at 12:11
0

I struggled with getting the plugin to work with Java 11 as well. Tried to detail the plugin dependencies to solve the issue:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-xjc-plugin</artifactId>
                <version>3.2.3</version>
                <dependencies>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-xjc</artifactId>
                        <version>${jaxb-api.version}</version>
                    </dependency>
                    <!-- Java Architecture for XML Binding (JAXB), Java 11+ support -->                                         
                    <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>${jaxb-api.version}</version>
                    </dependency>                       
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>${jaxb-api.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-core</artifactId>
                        <version>${jaxb-api.version}</version>
                    </dependency>
                    <!-- JavaBeans Activation Framework (JAF), Java 11+ support -->
                    <dependency>
                        <groupId>javax.activation</groupId>
                        <artifactId>javax.activation-api</artifactId>
                        <version>${jaf-api.version}</version>
                    </dependency>       
                    <!-- Java API for XML Web Services (JAX-WS), Java 11+ support -->
                    <dependency>
                        <groupId>javax.xml.ws</groupId>
                        <artifactId>jaxws-api</artifactId>
                        <version>${jaxws-api.version}</version>
                    </dependency>
                </dependencies>                 
            </plugin>               

.. with no luck. The issue went away when I upgraded to version 3.2.3 of the plugin (while waiting for 3.3.0 as described here: https://issues.apache.org/jira/browse/CXF-7852).