jaxws-maven-plugin multiple executions not working

2.2k Views Asked by At

I'd like to generate java classes for multiple WSDLs. Due to name conflicts in the different schemas, each WSDL should be in one java package. I created the following executions in my pom.xml:

  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>jaxws-maven-plugin</artifactId>
      <version>2.5</version>
      <executions>
        <execution>
          <id>service1</id>
          <goals>
            <goal>wsimport</goal>
          </goals>
          <configuration>
            <wsdlUrls>
              <wsdlUrl>http://myserver/service1?wsdl</wsdlUrl>
            </wsdlUrls>
            <keep>false</keep>
            <sourceDestDir>target/generatedclasses</sourceDestDir>
            <packageName>com.myservice1</packageName>
          </configuration>
        </execution>
        <execution>
          <id>service2</id>
          <goals>
            <goal>wsimport</goal>
          </goals>
          <configuration>
            <wsdlUrls>
              <wsdlUrl>http://myserver/service2?wsdl</wsdlUrl>
            </wsdlUrls>
            <keep>false</keep>
            <sourceDestDir>target/generatedclasses</sourceDestDir>
            <packageName>com.myservice2</packageName>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

But obviously the WSDL location can not be found:

[DEBUG] Configuring mojo org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport from plugin realm ClassRealm[plugin>org.codehaus.mojo:jaxws-maven-plugin:2.5, parent: sun.misc.Launcher$AppClassLoader@18b4aac2]
[DEBUG] Configuring mojo 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport' with basic configurator -->
[DEBUG]   (f) bindingDirectory = C:\sandbox\ws-client\src\jaxws
[DEBUG]   (f) destDir = C:\sandbox\ws-client\target\classes
[DEBUG]   (f) extension = false
[DEBUG]   (f) genJWS = false
[DEBUG]   (f) implDestDir = C:\sandbox\ws-client\src\main\java
[DEBUG]   (f) keep = true
[DEBUG]   (f) pluginDescriptor = Component Descriptor: role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.HelpMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:help'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.MainWsGenMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsgen'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.TestWsGenMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsgen-test'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.MainWsImportMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.TestWsImportMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport-test'
---
[DEBUG]   (f) project = MavenProject: org.example:wsclient:1.0-SNAPSHOT @ C:\sandbox\ws-client\pom.xml
[DEBUG]   (f) quiet = false
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@22680f52
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@39c11e6c
[DEBUG]   (f) sourceDestDir = C:\sandbox\ws-client\target\generated-sources\wsimport
[DEBUG]   (f) staleFile = C:\sandbox\ws-client\target\jaxws\stale
[DEBUG]   (f) useJdkToolchainExecutable = false
[DEBUG]   (f) verbose = false
[DEBUG]   (f) wsdlDirectory = C:\sandbox\ws-client\src\wsdl
[DEBUG]   (f) xadditionalHeaders = false
[DEBUG]   (f) xdebug = false
[DEBUG]   (f) xdisableAuthenticator = false
[DEBUG]   (f) xdisableSSLHostnameVerification = false
[DEBUG]   (f) xnoAddressingDataBinding = false
[DEBUG]   (f) xnocompile = true
[DEBUG]   (f) xuseBaseResourceAndURLToLoadWSDL = false
[DEBUG] -- end configuration --
[DEBUG] The wsdl Directory is C:\sandbox\ws-client\src\wsdl
[INFO] No WSDLs are found to process, Specify at least one of the following parameters: wsdlFiles, wsdlDirectory or wsdlUrls.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.808 s

I don't understand, why this example isn't working. It seems that the configuration is valid (see Multiple WSDLs Configurations With Maven JAXWS)

If I move the configuration element two levels up it works! (But I can only configure one execution...)

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>jaxws-maven-plugin</artifactId>
      <version>2.5</version>
      <executions>
        <execution>
          <goals>
            <goal>wsimport</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <wsdlUrls>
          <wsdlUrl>http://myserver/service1?wsdl</wsdlUrl>
        </wsdlUrls>
        <keep>false</keep>
        <sourceDestDir>target/generatedclasses</sourceDestDir>
        <packageName>com.myservice1</packageName>
      </configuration>
    </plugin>
  </plugins>
</build>

Any ideas for a solution are strongly appreciated!

(P.S. Java 8, Maven 3.6.2)

1

There are 1 best solutions below

0
On BEST ANSWER

The solution was to run the "install" Lifecycle rather than the plugin jaxws:import directly.