Having run into http://java.net/jira/browse/JAXB-131, we are trying to adopt the cure provided in its comments, which is to supply -enableIntrospection on xjc's command line.
However, when I do:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>allservice</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<xjcArgs><xjcArg>-enableIntrospection</xjcArg></xjcArgs>
<extension>true</extension>
<wsdlDirectory>src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
<bindingDirectory>src/main/resources/bindings</bindingDirectory>
<target>2.0</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>jsr181-api</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
The maven build fails with:
[DEBUG] The binding Directory is C:\Source\workspace\TheProject\src\main\resources\bindings
[DEBUG] jaxws:wsimport args: [-s, C:\Source\workspace\TheProject\target\jaxws\wsimport\java, -d, C:\Source\workspace\TheProject\target\classes, -target, 2.0, -extension, -Xnocompile, -B-enableIntrospection, -b, C:\Source\workspace\TheProject\src\main\resources\bindings\servicebindings.xml]
[INFO] jaxws:wsimport args: [-s, C:\Source\workspace\TheProject\target\jaxws\wsimport\java, -d, C:\Source\workspace\TheProject\target\classes, -target, 2.0, -extension, -Xnocompile, -B-enableIntrospection, -b, C:\Source\workspace\TheProject\src\main\resources\bindings\servicebindings.xml, C:\Source\workspace\TheProject\src\main\webapp\WEB-INF\wsdl\CaseService.wsdl]
no such JAXB option: -enableIntrospection
How can I use xjc's -enableIntrospection with jaxws-maven-plugin? If I can't, what alternatives exist to customize jaxws's code generation so that the getter for a Boolean
property is called getFoo()
(correct) rather than isFoo()
(which violates the Java Beans spec).
It appears that the jaxws-maven-plugin uses the xjc from the installed JDK. The newest Oracle JDK still contains a version of XJC before support for -enableIntrospection was added.
I next looked into using a JAXB-Plugin. It turns out that the jaxws-maven-plugin offers no easy way to append to the classpath of XJC, which is required to load JAXB-Plugins.
Replacing the jaxws-maven-plugin was not possible for political reasons (something like "jaxws is the standard, only standard libraries may be used").
I have therefore fallen back to writing a maven plugin that reads the source code after generation, does
content.replace("public Boolean is", "public Boolean get");
and writes the source file back to disk. That has also allowed me to inject definitions of equals()
and hashCode()
that rely on the naming convention for business keys in the API I am consuming.