7

I've been trying to get cxf-codegen-plugin working on Java 9 with some resistance. So far I've added java.se.ee to the runtime modules and added the necessary dependencies to maven.

However, when I try to build my sources I get the following error:

DefaultValidationEventHandler: [ERROR]: unexpected element (uri:"http://cxf.apache.org/tools/plugin", local:"databinding"). Expected elements are <{}databinding>,<{}frontend> 
 Location:  node: [databinding: null]
apr. 21, 2018 8:23:57 EM org.apache.cxf.tools.wsdlto.core.PluginLoader loadPlugin
ALLVARLIG: Tools plugin jar:file:/C:/Users/Daniel/.m2/repository/org/apache/cxf/cxf-tools-wsdlto-core/3.2.4/cxf-tools-wsdlto-core-3.2.4.jar!/META-INF/tools-plugin.xml load failed

Any ideas what might be causing this or how to fix it?

4 Answers4

3

Run into the same issue, I ended up changing the plugin configuration and adding the required modules explicitly:

 <plugin>
     <groupId>org.apache.cxf</groupId>
     <artifactId>cxf-codegen-plugin</artifactId>
     <version>3.2.4</version>
     <configuration>
         <additionalJvmArgs>--add-modules java.xml.bind,java.xml.ws</additionalJvmArgs>
         <fork>once</fork>
     </configuration>
 </plugin>

It seems to work for Java 9/10 but certainly not going to work for Java 11.

reta
  • 766
  • 6
  • 8
  • 2
    We'll have to wait for 3.3.0 to run it on java 11: https://issues.apache.org/jira/browse/CXF-7741 – Selaron Oct 11 '18 at 07:29
  • Has someone come up with the Java 11 solution? – Pat B Sep 09 '20 at 14:13
  • 1
    @PatB for JDK11+ you just need to provide the dependencies explicitly, see please https://github.com/apache/cxf/blob/master/maven-plugins/codegen-plugin/src/it/jaxb-xjc-runtime-sources/pom.xml for example. – reta Sep 10 '20 at 20:03
1

As the documentation said you have to start with version 3.2.5 cxf documentation for java 9

<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.5</version>
0

I tested with java 10:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.2.4</version>
    <configuration>
        <fork>true</fork>
        <additionalJvmArgs>--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</additionalJvmArgs>
    </configuration>
</plugin>

My maven execution file (windows):

set PATH=C:\Users\user\Documents\programs\jdk-10\bin;%PATH%
set JAVA_HOME=C:\Users\user\Documents\programs\jdk-10
set MAVEN_OPTS=--add-modules java.xml.bind
mvn clean install
Valentyn Kolesnikov
  • 2,029
  • 1
  • 24
  • 31
0

Using --add-modules fails when running with Java 8. To make the build compatible with both Java 8 and Java 9, I've added javax.xml.bind:jaxb-api as dependency of the plugin instead, which seems to work fine.

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <!-- ... -->
    </executions>
    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
    </dependencies>
</plugin>
kapex
  • 28,903
  • 6
  • 107
  • 121