JavaPulse

a finger on the pulse of the freelance Java™ market in the Netherlands

Configuring Maven2 plugin ‘axistools-maven-plugin’ for multiple executions

Posted on | 3 September 2007 | 3 Comments
Tags: |

The project I was converting to Maven produces a war file containing an Axis-generated web service. I had to execute all 3 goals of the axistools-maven-plugin: java2wsdl, then wsdl2java, then admin.

Rebinding to a different phase and compiling generated sources after normal classes are already compiled
Normally, wsdl2java is bound to the generate-sources phase and both java2wsdl and admin are bound to the process-classes phase. But I don’t have the wsdl to process in the wsdl2java until after the process-classes phase. So I bound the wsdl2java to the generate-test-sources phase and trick Maven into compiling the generated sources as test sources by setting the testSourceDirectory to the wsdl2java generated sources and testOutputDirectory to the same as the normal sources.

<testSourceDirectory>${basedir}/target/generated-sources/axistools/wsdl2java</testSourceDirectory>
<testOutputDirectory>${basedir}/target/classes</testOutputDirectory>

Configuring a plugin for multiple execution

Since this post was published, I found that there is another way to get the multiple executions of the same pom to be reinstantiated. So the following section is no longer valid. See Addendum: Configuring a Maven2 plugin for multiple execution. However, the next section ‘Different dependencies for different executions of the same plugin’ is still valid until the bug is fixed.

Then I ran into the Maven bug #MNG-1323 – plugins are instantiated only once and cached according to the groupId/artifactId during any given Maven run. This means that configurations are not reapplied and dependencies are not reloaded in subsequent executions of the same plugin. To workaround the first problem, I had to put all the configuration properties in the first invocation (java2wsdl):

<configuration>
  <!– java2wsdl –>
  <filename>${project.name}.wsdl</filename>
  <classOfPortType><path to interface or class of webservice></classOfPortType>
  <location><url for access to webservice></location>
  <namespace><namespace used in SOAP></namespace>
  <style>rpc</style>
  <typeMappingVersion>1.1</typeMappingVersion>
  <use>encoded</use>
  <!– wsdl2java –>
  <all>true</all>
  <serverSide>true</serverSide>
  <sourceDirectory>${basedir}/target/generated-sources/axistools/java2wsdl</sourceDirectory>
  <wsdlFiles><wsdlFile>${project.name}.wsdl</wsdlFile></wsdlFiles>
  <noWrapped>false</noWrapped>
  <mappings>
    <mapping>
      <namespace><namespace used for webservice, specified above></namespace>
      <targetPackage><package for generated sources for wsdl2java></targetPackage>
    </mapping>
  </mappings>
  <implementationClassName><path to implementation class of webservice></implementationClassName> <!– This will be generated as a template to be filled in, but because I started with a webservice implementation, the generated one should be delete from the target classes before packaging –>
  <servicePortName>${project.name}</servicePortName>
  <wrapArrays>false</wrapArrays> <!– This one must be specified to prevent mapping of arrays into lists. Notice that this was not configurable for axis ant tasks where it is false by default. –>
  <!– admin –>
  <inputFiles>
    <inputFile>${basedir}/target/generated-sources/axistools/wsdl2java/<remainder path to generated deploy descriptor>/deploy.wsdd</inputFile>
  </inputFiles>
  <isServerConfig>true</isServerConfig>
  <configOutputDirectory>${basedir}/target/${project.artifactId}-${version}/WEB-INF</configOutputDirectory>
</configuration>

Different dependencies for different executions of the same plugin
To workaround the second problem of applying different dependencies to different executions, I had to reinstall the plugin multiple times to different artifactId’s because the plugin are cached according to groupId/artifactId, so changing the version wouldn’t work. Then I found out that install:install-file doesn’t work for a plugin because the plugin descriptor would not be found. So I had to get the sources and invoke ‘mvn install’ for each set of dependencies after specifying the artifactId:

<artifactId>axistools-maven-plugin-dependencies1</artifactId>

The install from the sources will eventually call plugin:updateRegistry which makes the plugin descriptor available.

Comments

3 Responses to “Configuring Maven2 plugin ‘axistools-maven-plugin’ for multiple executions”

  1. JavaPulse » Addendum : Configuring a Maven2 plugin for multiple execution
    September 6th, 2007 @ 08:37

    [...] Specifying an id will allow separate configuration for each execution, but it does not reload dependencies. So if you need to use the same plugin with different dependencies, you still need to do a workaround such as the one I posted here under the section ‘Different dependencies for different executions of the same plugin’. [...]

  2. Tarandeep Singh
    November 5th, 2007 @ 14:29

    Hi Clara
    Thanks for Your post “Configuring Maven2 plugin ‘axistools-maven-plugin’ for multiple executions”. This is really useful.

    I’m also doing the similar task..but running into issues related to Wsdl2java rebinding. Can you please elaborate how i can implement solution which you have mentioned for “Rebinding to a different phase and compiling generated sources after normal classes are already compiled”. I’ve tried setting ${basedir}/target/generated-sources/axistools/wsdl2java
    ${basedir}/target/classes as you have suggested, but the problem still persists. Can you please take a look at my pom.xml below and advice some solution.

    regards
    tarandeep

    My Pom.xml is

    4.0.0
    com.mycompany.app
    my-app
    jar
    1.0-SNAPSHOT
    my-app
    http://maven.apache.org

    junit
    junit
    3.8.1
    test

    org.codehaus.mojo
    axistools-maven-plugin
    1.1

    org.codehaus.mojo
    axistools-maven-plugin

    ${basedir}/target/generated-sources/axistools/wsdl2java
    ${basedir}/target/classes

    com.mycompany.app.App
    ${project.name}.wsdl
    http://localhost:8080/axis/services/experian
    rpc
    http://com.thirdpillar
    ${project.build.outputDirectory}
    1.1

    true
    true
    ${basedir}/target/generated-sources/axistools/java2wsdl

    ${project.name}.wsdl

    false

    http://com.thirdpillar
    com.thirdpillar

    ${project.name}
    false

    ${basedir}/target/generated-sources/axistools/wsdl2java/com/thirdpillar/deploy.wsdd

    true
    C:\NewTomcat\apache-tomcat-5.5.23\webapps\axis\WEB-INF

    java2wsdl
    wsdl2java
    admin

  3. Ignacio Perez
    December 15th, 2008 @ 08:40

    Here is my solution for your problem:

    org.codehaus.mojo
    axistools-maven-plugin
    1.2

    java2wsdl
    generate-sources

    java2wsdl

    com.matchmind.ws.SayHiWS
    fichero.wsdl
    ${project.artifactId}SoapBinding
    http://localhost:8080/${project.artifactId}/services/${project.artifactId}
    http://com.mycompany.app
    ${basedir}/src/main/webapp/wsdl
    ${project.artifactId}
    LITERAL

    wsdl2java

    wsdl2java

    com.matchmind.ws
    ${basedir}/src/main/java
    ${basedir}/src/main/webapp/wsdl
    true
    false
    com.matchmind.ws.SayHiWS

    admin

    admin

    ${basedir}/src/main/java/com/matchmind/ws/deploy.wsdd

    ${basedir}/src/main/webapp/WEB-INF
    true

Leave a Reply