Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultValuePlugin: IllegalArgumentException when elements come with an inline anonymous type definition #21

Open
mgrobarek opened this issue Feb 1, 2024 · 6 comments

Comments

@mgrobarek
Copy link

I’m currently migrating to your default value xjc plugin when I encountered the following problem:

[main] INFO org.jvnet.basicjaxb.plugin.defaultvalue.DefaultValuePlugin - XJC> XdefaultValue: : Start
Parameters
  Verbose.: true
  Debug...: true
[main] ERROR org.jvnet.basicjaxb.plugin.defaultvalue.DefaultValuePlugin - XJC> XdefaultValue: IllegalArgumentException: local part cannot be "null" when creating a QName
[main] INFO org.jvnet.basicjaxb.plugin.defaultvalue.DefaultValuePlugin - XJC> XdefaultValue: : Finish
Results
  HadError.: true

WSDLToJava Error: Error during plugin execution.


org.apache.cxf.tools.common.ToolException: Error during plugin execution.

	at org.apache.cxf.tools.common.ToolErrorListener.throwToolException(ToolErrorListener.java:87)
	at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:149)
	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 org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
Caused by: org.xml.sax.SAXParseException; Error during plugin execution.
	at org.jvnet.basicjaxb.plugin.AbstractPlugin.handleException(AbstractPlugin.java:135)
	at org.jvnet.basicjaxb.plugin.AbstractPlugin.run(AbstractPlugin.java:264)
	at com.sun.tools.xjc.model.Model.generateCode(Model.java:263)
	at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:265)
	at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:65)
	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:146)
	... 5 more
Caused by: java.lang.IllegalArgumentException: local part cannot be "null" when creating a QName
	at java.xml/javax.xml.namespace.QName.<init>(QName.java:185)
	at java.xml/javax.xml.namespace.QName.<init>(QName.java:129)
	at org.jvnet.basicjaxb.plugin.defaultvalue.DefaultValuePlugin.processClassOutline(DefaultValuePlugin.java:325)
	at org.jvnet.basicjaxb.plugin.defaultvalue.DefaultValuePlugin.run(DefaultValuePlugin.java:231)
	at org.jvnet.basicjaxb.plugin.AbstractPlugin.run(AbstractPlugin.java:259)
	... 12 more

This happens for the following element definition:

<xsd:element name="Limit" default="1000" minOccurs="0">
    <xsd:simpleType>
        <xsd:restriction base="xsd:int">
            <xsd:minInclusive value="1" />
            <xsd:maxInclusive value="10000" />
        </xsd:restriction>
    </xsd:simpleType>
</xsd:element>

The simpleType used for the Limit element has no name, hence the QName cannot be instantiated in DefaultValuePlugin.java:325.
I can work around this issue by adding an explicit name for the inline type in my XSD, like this: <xsd:simpleType name="LimitInt">

But in my case, the XSD comes from outside my project and I can’t change it on my own. Hence it would be nice to have the DefaultValuePlugin to ignore such empty names.

I’m using:

  • org.patrodyne.jvnet:hisrc-basicjaxb-plugins:2.2.0
  • org.glassfish.jaxb:jaxb-xjc:4.0.4
  • org.apache.cxf:cxf-tools-wsdlto-core:4.0.3
  • Eclipse Temurin 17.0.9+9
@patrodyne
Copy link
Owner

patrodyne commented Feb 1, 2024

Thank you for reporting this issue. A new commit 5be585a includes your Limit example, in the unit test, and a modification to DefaultValuePlugin to handle anonymous types. It will be included in the next release (no ETA).

@SebGuillomon
Copy link

Hello,

I faced the same issue and default value is a key featurefor me.
When is planned version 2.2.1 ?

Many thanks

@patrodyne
Copy link
Owner

patrodyne commented Mar 14, 2024

I believe the current release period will be shorter than past periods. Note: I refrain from guessing ETAs.

@patrodyne
Copy link
Owner

The DefaultValuePlugin has been released to Maven Central.

@SebGuillomon
Copy link

Thanks for release,

Using Maven plugin "org.patrodyne.jvnet:hisrc-higherjaxb-maven-plugin:2.2.0" with this dependency (only this release available), I have this error

[ERROR] Failed to execute goal org.patrodyne.jvnet:hisrc-higherjaxb-maven-plugin:2.2.0:generate (default) on project plma-tools-commons: Execution default of goal org.patrodyne.jvnet:hisrc-higherjaxb-maven-plugin:2.2.0:generate failed: An API incompatibility was encountered while executing org.patrodyne.jvnet:hisrc-higherjaxb-maven-plugin:2.2.0:generate: java.lang.NoSuchMethodError: 'boolean org.jvnet.basicjaxb.util.FieldUtils.isConstantField(com.sun.tools.xjc.outline.FieldOutline)'

@patrodyne
Copy link
Owner

The hisrc-higherjaxb-maven-plugin v2.2.1 should be available to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants