Category Archives: cxf-codegen-plugin

cxf-codegen-plugin not generating proxies everytime

In case this helps others out…

I am working on a Java project at the moment using Maven to build the code and run tests etc. I’m also using the cxf-codegen-plugin plugin (as below) to generate some proxies for a soap/wsdl file I have.

<plugin>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-codegen-plugin</artifactId>
   <version>3.2.2</version>
   <executions>
      <execution>
         <id>generate-sources</id>
         <phase>generate-sources</phase>
         <configuration>
         <wsdlOptions>
            <wsdlOption>
               <wsdl>${project.basedir}/src/main/resources/wsdl/Svc.wsdl</wsdl>
               <wsdlLocation>classpath:wsdl/Svc.wsdl</wsdlLocation>
               <extraargs>
                  <extraarg>-verbose</extraarg>
                  <extraarg>-client</extraarg>
                  <extraarg>-p</extraarg>
                  <extraarg>com.putridparrot.soap</extraarg>
               </extraargs>
            </wsdlOption>
         </wsdlOptions>
         </configuration>
         <goals>
            <goal>wsdl2java</goal>
         </goals>
      </execution>
   </executions>
</plugin>

I found that when I tried to either use mvn generate-sources mvn install the generated source folder was deleted and recreated, however the proxies folder had no proxy code/files (i.e. the files were deleted and not regenerated).

If I ran mvn clean install the proxy code would re-appear, but subsequent calls to generate-source of install would again delete the proxy code/files.

To cut a long story short it appeared that another plugin was clearing out the generated-sources folder but the cxf-codegen-plugin plugin would not regenerate it’s proxy code/files because of another file which the plugin created in the cxf-codegen-plugin-markers folder.

Within this folder is a file with a UUID style name. This was being plugin used by the plugin to check whether it needed to regenerate it’s proxy code/files (it doesn’t check if the files exist or simply regenerate them each time it’s run).

You can recreate the problem easily by running mvn generate-sources to create the proxies, then delete the generated-sources folder and run mvn generate-sources again. No proxy files are created. Now delete the marker file and the proxies will get regenerated.

Deleting this folder (or just the file within it) will fix the problem.

To stop this happening again you can either ensure the folder or file are deleted when the generate-sources folder is deleted or even simpler just write your proxies to another folder, so this would now get deleted by the other plugins.

i.e.

<configuration>
   <sourceRoot>${project.build.directory}/cxf</sourceRoot>
   <!-- other config -->
</configuration>