I am using Apache CXF 2.x, Eclipse Luna 64-bit, Maven 3.x
I have a single web service producer app that has a WSDL and I want the Stubs in the app to generate dynamically from the WSDL.
I have installed the Maven Lifecycle Dependency and installed both M2E WTP connectors. In Eclipse Project -> Properties -> Maven -> Lifecycle Mapping, I see cxf-codegen-plugin:wsdl2java and it shows that it is properly attached to the generate-sources lifecycle phase.
When I run mvn install
manually, the stubs are generated automatically and everything works fine.
But if I clean the maven project and load it in eclipse, eclipse does not automatically generate the stubs. I see Java missing class errors in Eclipse workspace showing the gen is not occurring.
What step am I missing?
Here is the POM that I am using.
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>testWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>testWeb</name>
<properties>
<cxf.version>2.1.3</cxf.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<spring.version>3.2.2.RELEASE</spring.version>
</properties>
<repositories>
<repository>
<id>snapshots</id>
<name>ILP Snapshot Repository</name>
<url>http://dhud001.test.com:8675/maven_snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>eclipse</id>
<name>Eclipse</name>
<url>https://repo.eclipse.org/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<useCompileClasspath>true</useCompileClasspath> <!-- if you don't use this, the soapui test bundle will cause classloading issues with this plugin. -->
<sourceRoot>${project.basedir}/src/gen/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.basedir}/src/main/webapp/wsdl/TestService.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/TestService.wsdl</wsdlLocation>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-all</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I was able to install Build helper maven connector and also tried to install https://code.google.com/a/eclipselabs.org/p/m2e-cxf-codegen-connector/ as well. But the sources continue to not generate.
Example eclipse project that can reproduce the problem is here: https://www.dropbox.com/s/vlo0ghbmkplu7au/service.zip?dl=0
I'm not sure what you were expecting in what circumstances but there appears to be a problem with the lifecycle mapping for the cxf m2e plugin, in that the clean mechanism isn't cleaning target folders appropriate to that plugin.
So, just delete the target folder manually (or at least delete the "cxf-codegen-plugin-markers" sub-folder) and then run a build. This should get the java files generated where needed.
You can also execute maven goals via the Run or Debug context menu items. Maven does delete the whole "target" folder on clean. So running a clean and an install from the context run menu (or from a maven run configuration) would also do what you need.
Note that command line maven didn't like your "cxf" dependency and it doesn't appear to be needed, anyway. I had to delete it to get this to work.
One last thing, the cxf plugin is also not refreshing the project after an eclipse build, which is needed to see what is generated in the build. So a quick F5 on the eclipse project is needed after a build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With