Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
3.3.2
-
None
-
OpenJDK 12
-
Unknown
Description
JAXB generates an is-prefix getter for a boolean data type in my WSDL instead of a get-prefix getter, see https://www.ibm.com/developerworks/community/blogs/Dougclectica/entry/JAXB_with_Java_7_and_xs_boolean?lang=en
The workaround is simple - pass the "-enableIntrospection" argument to the JAXB compiler. Unfortunately, CXF fails with this error -
Caused by: com.sun.tools.xjc.BadCommandLineException: grammar is not specified
at com.sun.tools.xjc.Options.parseArguments(Options.java:861)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
The test code to reproduce this is very simple -
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
String[] schemaCompilerOptions = new String[] {"-enableIntrospection"};
factory.setSchemaCompilerOptions(schemaCompilerOptions);Client client = factory.createClient(<wsdlUrl>);
The error occurs in org.apache.cxf.endpoint.dynamic.DynamicClientFactory#createSchemaCompiler
if (schemaCompilerOptions != null && schemaCompilerOptions.length > 0)
Unknown macro: { compiler.getOptions().parseArguments(schemaCompilerOptions); }
parseArguments expects the XML Schemas to have already been added to the compiler.getOptions() object, but in DynamicClientFactory, the schemas are added after parseArguments is called, which is why parseArguments spits out the "grammar is not specified" error.
This can be fixed in a couple of ways -
- Add a dummy schema to the compiler.getOptions() object before invoking parseArguments on it.
- Relocate the call to parseArguments after the schemas have been added to the compiler.getOptions() object.
Option 1 is used by org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding in its initialize() method -
// keep parseArguments happy, supply dummy required command-line opts
opts.addGrammar(new InputSource("null"));
opts.parseArguments(args.toArray(new String[0]));
Personally, I prefer relocating the call instead of adding a dummy schema.
Attachments
Issue Links
- relates to
-
CXF-8580 maven cxf-codegen-plugin + jaxb2-rich-contract-plugin = BadCommandLineException: Error setting up group-interface-plugin, FileNotFoundException: target/null
- Closed
- links to