Wednesday, 10 August 2011

jaxws-maven-plugin

I like maven as a build management tool. It provides a predefined and flexible folder structure, a dependency management mechanism enabling using versioned dependencies, plugins, project organization as modules and profiles.
All these things nowadays are considered quite common for a java project, probably nobody wants to revert back to a manual build system.
Maven is so popular that there are hundreds of plugins of it, from unit test execution to stub/proxy generation. Having a huge availability of plugins may cause taking risk of unfound bugs in these plugins and having delayed delivery times. Generally plugins are contributed by open source committers so there isn’t any dedicated resource for most plugins to fix bugs found in a plugin.
One of these popular plugins is jaxws-maven-plugin generally used for java proxy creation from a wsdl file or vice-versa. It’s developed by java.net and including some bugs like all other plugins.
I was thinking of jaxws-maven-plugin as a high quality tool, at least expecting some dedicated support from java.net and Sun/Oracle guys. Apparently I was wrong as this tool includes a bug not fixed more than two years!.
The bug can be observed while trying to create proxy classes from two or more wsdl files by creating two execution sections, see below, inside the plugin configuration.
Second.wsdl file is not processed by the below plugin configuration, might cause us to spend time wondering why the second one is not processed.
Thanks to another guy for pointing out this issue and finding the actual underlying bug, I didn’t spend much time for a workaround.
But the main issue with that particular plugin is that this bug was reported in Jan’ 09 and it hasn't being fixed so far!.


Default jaxws configuration


<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>jaxws-maven-plugin</artifactId>
 <version>1.10</version>
 <executions>
  <execution>
   <id>execution-one</id>
   <configuration>
    <wsdlDirectory>src/main/resources</wsdlDirectory>
    <wsdlFiles>
     <wsdllFile>First.wsdl</wsdllFile>
    </wsdlFiles>
    <packageName>tr.asahin.first.webservice</packageName>
    <keep>true</keep>
   </configuration>
   <goals>
    <goal>wsimport</goal>
   </goals>
  </execution>
  <execution>
   <id>execution-twot</id>
   <phase>generate-sources</phase>
   <configuration>
    <wsdlDirectory>src/main/resources</wsdlDirectory>
    <wsdlFiles>
     <wsdllFile>Second.wsdl</wsdllFile>
    </wsdlFiles>
    <packageName>tr.asahin.second.webservice</packageName>
    <keep>true</keep>
    <extension>true</extension>
   </configuration>
   <goals>
    <goal>wsimport</goal>
   </goals>
  </execution>
 </executions>
</plugin>



Applying a workaround

<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>jaxws-maven-plugin</artifactId>
 <version>1.10</version>
 <executions>
  <execution>
   <id>execution-one</id>
   <configuration>
    <wsdlDirectory>src/main/resources</wsdlDirectory>
    <wsdlFiles>
     <wsdllFile>First.wsdl</wsdllFile>
    </wsdlFiles>
    <packageName>tr.asahin.first.webservice</packageName>
    <keep>true</keep>
    <staleFile>${project.build.directory}/jaxws/stale/first.txt</staleFile>
   </configuration>
   <goals>
    <goal>wsimport</goal>
   </goals>
  </execution>
  <execution>
   <id>execution-twot</id>
   <phase>generate-sources</phase>
   <configuration>
    <wsdlDirectory>src/main/resources</wsdlDirectory>
    <wsdlFiles>
     <wsdllFile>Second.wsdl</wsdllFile>
    </wsdlFiles>
    <packageName>tr.asahin.second.webservice</packageName>
    <keep>true</keep>
    <staleFile>${project.build.directory}/jaxws/stale/second.txt</staleFile>
    <extension>true</extension>
   </configuration>
   <goals>
    <goal>wsimport</goal>
   </goals>
  </execution>
 </executions>
</plugin>

No comments:

Post a Comment