bjornvester / wsdl2java-gradle-plugin

A Gradle plugin for generating Java classes from WSDL files
MIT License
40 stars 14 forks source link

Option -Xcollection-setter-injector does not work #26

Open istvan-hegedus opened 1 year ago

istvan-hegedus commented 1 year ago

I tried to configure the wsdl2java plugin with -Xcollection-setter-injector as follows:

wsdl2java {
    options.add("-xjc-Xcollection-setter-injector")
    wsdlDir = layout.projectDirectory
    includesWithOptions = ["src/main/resources/wsdl/service.wsdl" : ["-wsdlLocation", "http://localhost/wsdl/service.wsdl"]
    cxfVersion = "4.0.2"
    useJakarta = true
}

Without the option everything works as expected, but with the option I got the following exception:

...
Caused by: java.lang.NoSuchMethodError: 'com.sun.xml.bind.api.impl.NameConverter com.sun.tools.xjc.model.Model.getNameConverter()'
        at com.sun.tools.xjc.addon.collection_setter_injector.PluginImpl.declareMethod(PluginImpl.java:169)
        at com.sun.tools.xjc.addon.collection_setter_injector.PluginImpl.run(PluginImpl.java:142)
        at com.sun.tools.xjc.model.Model.generateCode(Model.java:262)
        at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:255)
        at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:67)
        at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:445)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:711)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:259)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:156)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:402)
        at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
        at com.github.bjornvester.wsdl2java.Wsdl2JavaWorker.execute(Wsdl2JavaWorker.kt:18)
...

Before migration from javax to jakarta stuff we used net.java.dev.vcc.thirdparty:collection-setter-injector:0.5.0-1. I tried to use org.andromda.thirdparty.jaxb2_commons:collection-setter-injector:1.0, but the result is the same.

Do you have any idea what kind of collection-setter-injector we could use?

Thank you for your help in advance.

istvan-hegedus commented 1 year ago

I forked the org.andromda.thirdparty.jaxb2_commons:collection-setter-injector:1.0 with a simple modification of import com.sun.xml.bind.api.impl.NameConverter; => import org.glassfish.jaxb.core.api.impl.NameConverter; in the com.sun.tools.xjc.addon.collection_setter_injector.PluginImpl and it started to work. If you know an already patched artifact, let me know. Thanks!