[ 
https://issues.apache.org/jira/browse/CXF-8052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Freeman Fang reassigned CXF-8052:
---------------------------------

    Assignee: Freeman Fang

> Cannot set JAXB schema compiler options
> ---------------------------------------
>
>                 Key: CXF-8052
>                 URL: https://issues.apache.org/jira/browse/CXF-8052
>             Project: CXF
>          Issue Type: Bug
>          Components: Simple Frontend
>    Affects Versions: 3.3.2
>         Environment: OpenJDK 12
>            Reporter: Ranjit Vadakkan
>            Assignee: Freeman Fang
>            Priority: Blocker
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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 -
> {quote}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)
>  ...
> {quote}
>  
> The test code to reproduce this is very simple -
> {quote}JaxWsDynamicClientFactory factory = 
> JaxWsDynamicClientFactory.newInstance();
> String[] schemaCompilerOptions = new String[] \{"-enableIntrospection"};
> factory.setSchemaCompilerOptions(schemaCompilerOptions);
> Client client = factory.createClient(<wsdlUrl>);
> {quote}
>  
> The error occurs in 
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory#createSchemaCompiler
> {quote}if (schemaCompilerOptions != null && schemaCompilerOptions.length > 0) 
> {
>      compiler.getOptions().parseArguments(schemaCompilerOptions);
> }
> {quote}
>  
> 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 -
> {quote}// keep parseArguments happy, supply dummy required command-line opts
> opts.addGrammar(new InputSource("null"));
> opts.parseArguments(args.toArray(new String[0]));
> {quote}
>  
> Personally, I prefer relocating the call instead of adding a dummy schema.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to