Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CXF auto generation fails with "Duplicated option: frontend" in maven?

I have set up a simple cxf maven auto generation from a WSDL file. But I get the following exception. What am I missing?

Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.0.0:wsdl2java failed: org.apache.cxf.tools.common.toolspec.parser.BadUsageException: Duplicated option: frontend (org.apache.cxf:cxf-codegen-plugin:3.0.0:wsdl2java:generate-sources:generate-sources)

pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>

                    <configuration>
                      <defaultOptions>
                          <extraargs>
                              <extraarg>-fe</extraarg>
                              <extraarg>cxf</extraarg> 
                          </extraargs>
                      </defaultOptions>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${project.basedir}/src/main/resources/MyService.wsdl</wsdl>
                                <wsdlLocation>classpath:/MyService.wsdl</wsdlLocation>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>


                 </plugin>
        </plugins>
    </build>
    <dependencies>

            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-frontend-jaxws</artifactId>
                <version>3.0.0</version>
            </dependency>
 <dependencies>

Maven debug shows the following:

[DEBUG] Calling wsdl2java with args: [-encoding, UTF-8, -d, \target\generated\src\main\java, -fe, cxf, -fe, cxf, -wsdlLocation, classpath:wsdl/MyService.wsdl,...

Why is the frontent -fe created twice??

like image 277
membersound Avatar asked Sep 04 '25 17:09

membersound


2 Answers

Remove that <extraargs><extraarg>-fe</extraarg><extraarg>cxf</extraarg></extraargs> section.

Add this extraarg in wsdlOption

<wsdlOption>
    <extraarg>-autoNameResolution</extraarg>
</wsdlOption>
like image 98
Dinal Avatar answered Sep 06 '25 23:09

Dinal


Ran into the exact same problem. You have to disable the directory scan. Then you can keep the extraargs in the default options and don't have to repeat them for all the wsdlOptions.

      <configuration>
          <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
          <disableDirectoryScan>true</disableDirectoryScan>
          <defaultOptions>
            <extraargs>
              <extraarg>-verbose</extraarg>
              <extraarg>-validate</extraarg>
              <extraarg>-client</extraarg>
              <extraarg>-suppress-generated-date</extraarg>
            </extraargs>
          </defaultOptions>
          <!--wsdlOptions--> 
      </configuration>   
like image 41
Matthias T Avatar answered Sep 06 '25 22:09

Matthias T