You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Jan Litvik (Jira)" <ji...@apache.org> on 2023/05/25 07:25:00 UTC

[jira] [Created] (CXFXJC-44) cxf-xjc-dv generates compilation failure when XJC simple binding mode is used

Jan Litvik created CXFXJC-44:
--------------------------------

             Summary: cxf-xjc-dv generates compilation failure when XJC simple binding mode is used
                 Key: CXFXJC-44
                 URL: https://issues.apache.org/jira/browse/CXFXJC-44
             Project: CXF XJC Utils
          Issue Type: Bug
          Components: DV Plugin
    Affects Versions: 4.0.0
            Reporter: Jan Litvik


I am using cxf-xjc-plugin v 4.0.0 to generate java code from xsd. 
Java code is generated without issue until I use cxf-xjc-dv(v 4.0.0) plugin.
In this case Compilation failure is thrown: java.util.List is abstract; cannot be instantiated
The problematic piece of code: 
List<Serializable> andsAndOrsAndNots = new List<Serializable>();
Issue is similar to this https://issues.apache.org/jira/browse/CXFXJC-7
I investigated the behavior and found out that issue occurs when binding file is configured and it contains xjc:simple binding mode.
When XJC simple binding mode or cxf-xjc-dv plugin is not used, java code is generated but it does not meet our requirements.
 
*Schema definition snippet:*
{code:java}
    <xs:element name="query">
        <xs:complexType>
            <xs:choice>
                <xs:element ref="and"/>
                <xs:element ref="or"/>
                <xs:element ref="not"/>
                <xs:sequence>
                    <xs:element name="table" type="StringRequired"/>
                    <xs:element name="column" type="StringRequired"/>
                    <xs:element name="operator" type="StringRequired"/>
                    <xs:element name="value" type="xs:string"/>
                </xs:sequence>
            </xs:choice>
        </xs:complexType>
    </xs:element>

    <xs:element name="and">
        <xs:complexType>
            <xs:choice minOccurs="2" maxOccurs="unbounded">
                <xs:element ref="and"/>
                <xs:element ref="or"/>
                <xs:element ref="not"/>
                <xs:element ref="query"/>
            </xs:choice>        
        </xs:complexType>
    </xs:element>
    <xs:element name="or">
        <xs:complexType>
            <xs:choice minOccurs="2" maxOccurs="unbounded">
                <xs:element ref="and"/>
                <xs:element ref="or"/>
                <xs:element ref="not"/>
                <xs:element ref="query"/>
            </xs:choice>
        </xs:complexType>
    </xs:element>    
    <xs:element name="not">
        <xs:complexType>
            <xs:choice>
                <xs:element ref="and"/>
                <xs:element ref="or"/>
                <xs:element ref="not"/>
                <xs:element ref="query"/>
            </xs:choice>
        </xs:complexType>
    </xs:element>    
    <xs:simpleType name="StringRequired">
        <xs:restriction base="xs:string">
            <xs:minLength value="1" />
        </xs:restriction>
    </xs:simpleType>


{code}
 
*Maven:*
{code:java}
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-xjc-plugin</artifactId>
                <version>4.0.0</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xsdtojava</goal>
                        </goals>
                        <configuration>
                            <xsdOptions>
                                <xsdOption>
                                    <xsd>${basedir}/src/main/resources/query.xsd</xsd>
                                    <bindingFile>
                                        ${basedir}/src/main/jaxbconfig/config_jaxb.xjb</bindingFile>
                                    <extension>true</extension>
                                    <extensionArgs>
                                        <arg>-Xdv</arg>
                                    </extensionArgs>
                                </xsdOption>
                            </xsdOptions>
                            <extensions>
                                <extension>
                                    org.apache.cxf.xjcplugins:cxf-xjc-dv:4.0.0</extension>
                            </extensions>
                        </configuration>
                    </execution>
                </executions>
            </plugin> {code}
*JAXB binding config:*
{code:java}
<jaxb:bindings xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" version="3.0">
    
    <jaxb:globalBindings>
        <xjc:simple/>
        <jaxb:serializable uid="1" />
    </jaxb:globalBindings>
    
</jaxb:bindings>     {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)