1
votes

When I add the plugin to the pom file, I get an error on the application and I cannot create my service.

I'm trying to get the cxf-codegen-plugin to generate sources from my wsdl file.I did research but couldn't find a solution.I need your help.

console output:in the problems tab

Error: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java failed: A required class was missing while executing org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java: javax/xml/bind/annotation/adapters/HexBinaryAdapter

error resource: pom.xml

POM.XML

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
.......................................................................................................
     <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>3.1.6</version>
            <executions>
               <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/resources/wsdl/ProjectName.wsdl</wsdl>
                                <extraargs>                
                                    <extraarg>-verbose</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution> 
            </executions>
        </plugin>

Windows 10, x64, Jdk1.8.0_212,Spring Tools Suite(4.9.0.RELEASE)

Spring tools suite Features: Jdk Compiler :1.8. Installed JREs:jre1.8.0_241

My English language is not good.Excuse me.

Thank you.

1

1 Answers

0
votes

I'm not entirely sure why this class can't be found. You're using Java 8, and JAXB should still be part of the JDK in that version (versions 9 and 10 have it in module java.se.ee, 11+ have it removed completely).

You could try adding JAXB as a dependency of your plugin:

<plugin>
  <!-- your config omitted for brevity -->
  <dependencies>
    <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>2.3.1</version>
    </dependency>
  </dependencies>
</plugin>

Though this only adds the JAXB API, and not the actual implementations. One possible implementation is that of Glassfish:

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

Which you can also add to the same section.

Again, I'm not entirely sure if this will work (as JAXB should be present on your classpath due to using Java 8), but it's worth a try.