0

I want to use cxf-codegen-plugin to generate-sources with wsdl2java in my camel maven project.

I added the plugin as follows to my pom.

<plugin>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-codegen-plugin</artifactId>
   <version>3.2.4</version>
   <executions>
     <execution>
       <id>generate-sources</id>
       <phase>generate-sources</phase>
       <configuration>
         <wsdlOptions>
           <wsdlOption>
             <wsdl>src/main/resources/wsdl/BookService.wsdl</wsdl>
           </wsdlOption>
         </wsdlOptions>
       </configuration>
       <goals>
         <goal>wsdl2java</goal>
       </goals>
     </execution>
   </executions>
 </plugin>

This throws an error in the pom...

Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.2.4:wsdl2java failed: A required class was missing while executing org.apache.cxf:cxf-codegen-
 plugin:3.2.4:wsdl2java: javax/xml/bind/annotation/adapters/HexBinaryAdapter ----------------------------------------------------- realm = plugin>org.apache.cxf:cxf-codegen-
 plugin:3.2.4 strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy urls[0] = file:/C:/esb/.m2/repository/org/apache/cxf/cxf-codegen-plugin/3.2.4/cxf-codegen-
 plugin-3.2.4.jar urls[1] = file:/C:/esb/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar urls[2] = file:/C:/esb/.m2/repository/org/codehaus/plexus/plexus-
 archiver/1.2/plexus-archiver-1.2.jar ...

I tried other example projects like https://github.com/sigreen/camel-cxf-soap-client and got similar errors in the pom Since I am sure it worked back in 2015 when this project was committed, I assume it is a version mismatch today.

If someone has a recent project with cxf-codegen-plugin that would help.

Mike Oliver
  • 163
  • 1
  • 3
  • 14
  • I even tried to add it to the Camel cxf code first quickstart and even that throws errors ... Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.2.4:wsdl2java failed: A required class was missing while executing org.apache.cxf:cxf-codegen- plugin:3.2.4:wsdl2java: javax/xml/bind/annotation/adapters/HexBinaryAdapter – Mike Oliver Jun 01 '21 at 02:26
  • added two dependencies based on the error stack... javax.xml.bind jaxb-api 2.3.1 javax.xml.ws jaxws-api 2.1 I added the bookstore.wsdl – Mike Oliver Jun 01 '21 at 03:07
  • Now the missing files are replaced with errors in the BookService.wsdl ... The part 'parameters' has an invalid value 'GetBooksList' defined for its element. Element declarations must refer to valid values defined in a schema. – Mike Oliver Jun 01 '21 at 03:10

3 Answers3

1

I changed my jdk version from 11 to 8 and it works for me

farid raad
  • 11
  • 2
0

I kept making changes based on details in the error stacks that kept changing with each change. Here is the final plugin entry in the pom that was clean...

<plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.2.4</version>
                <dependencies>
                    <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
                    <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.3.1</version>
                    </dependency>
                    <!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
                    <dependency>
                        <groupId>javax.xml.ws</groupId>
                        <artifactId>jaxws-api</artifactId>
                        <version>2.1</version>
                    </dependency>
                    <!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
                    <dependency>
                        <groupId>javax.jws</groupId>
                        <artifactId>javax.jws-api</artifactId>
                        <version>1.1</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>src/main/resources/wsdl/BookService.wsdl</wsdl>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
Mike Oliver
  • 163
  • 1
  • 3
  • 14
0

for the following configuration:

<plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.5.2</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- <sourceRoot>${project.build.sourceDirectory}/generated-sources/cxf</sourceRoot>-->
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>src/main/resources/9874.wsdl
                                    </wsdl>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

I used this dependency and it worked well:

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf</artifactId>
            <version>3.17.0</version>
            <scope>provided</scope>
        </dependency>