Giter Site home page Giter Site logo

jaxb-xew-plugin's People

Contributors

bertramn avatar davidfmatheson avatar diorcety avatar dmak avatar kermit-the-frog avatar patrickcrocker avatar sebisteiner avatar thetric avatar wumpz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jaxb-xew-plugin's Issues

XmlElementWrapperPlugin fails with NullPinterException when using binding config fixedAttributeAsConstantProperty=true

When configuring XJC to turn fixed attributes into Java constants, the XmlElementWrapperPlugin fails with NullPointerException on line 399.

<jaxb:globalBindings fixedAttributeAsConstantProperty="true" />

and a fixed schema definition such as

<xsd:attribute name="Type" use="required" fixed="OTH">
    <xsd:simpleType>
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="3"/>
            <xsd:maxLength value="3"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:attribute>

Issue and related line numbers against the 1.2 version tag of the plugin. As far as I can tell this is caused by XJC storing the public name of the field in capital letters to conform to Java constant code style in com.sun.tools.xjc.model.CPropertyInfo but when the XmlElementWrapperPlugin pulls out the field name on line 365 it gets the private name which is all small letters due to the hard coded param in getName(). Later when the plugin tries to reference the field in method call implClass.fields().get(fieldName) on line 386 it can't actually find the field in the implClass fields map because it is keyed against the public (capital) name not the private one. I'll submit a working example when I get a bit of time but its pretty easy to replicate.

ConcurrentModificationException w/ jaxb2-basics 0.13.1

While using jaxb-xew-plugin 1.7 and jaxb2-basics 0.13.1 a ConcurrentModificationException is thrown.

Downgrading jaxb-xew-plugin to 1.2 resolves the issue

Link to jaxb2-basics issue: highsource/jaxb2-basics#72

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.806 s
[INFO] Finished at: 2016-07-27T14:07:46-05:00
[INFO] Final Memory: 18M/310M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate (generate) on project aaa.bbb.ccc: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed. ConcurrentModificationException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

Full stacktrace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate (generate) on project aaa.bbb.ccc: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:394)
at java.util.LinkedHashMap$ValueIterator.next(LinkedHashMap.java:409)
at org.jvnet.jaxb2_commons.plugin.codegenerator.AbstractCodeGeneratorPlugin.run(AbstractCodeGeneratorPlugin.java:72)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:292)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:66)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:41)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:505)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:328)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more

Xew does not remove list in a multi episode compilation

Hi there,

I have a pretty twisted case where we string together multiple episode compilations (like common types , data model , message model and wsdl). The data model is generated as an episode usgin jaxb and the message model is part of the cxf jaxws compilation. The unfortunate thing is that the model and message schemata all have the same namespace and we resort to a hack of the model episode file (we set jaxb:schemaBindings/@map='true') to make sure we can generate the remainder of the schema types defined in the message model.

In the message model I have a ContactList class that gets removed by xew plugin when processing the model but when the CXF processing happens an episode later, the xew plugin considers these classes again (as they are not listed in the previous episode file from the model) but at this stage does not remove them.

I created an example to demonstrate this: https://github.com/bertramn/cxf-wsdlgen-issue/tree/xew-issue

Sorry the example smells like a hack but there is an issue in cxf that I am trying to track down and hopefully find a workaround for.

When the model is compiled xew reports that it eradicates ContactList, which is correct:

[INFO]   JAXB version         : 2.2.11
[INFO]   Control file         : <none>
[INFO]   Summary file         : <none>
[INFO]   Instantiation mode   : EARLY
[INFO]   Collection impl      : java.util.ArrayList
[INFO]   Collection interface : java.util.List
[INFO]   Plural form          : false
[INFO]
[INFO] Candidates:
[INFO]  [+]: model.ContactList
[INFO]  1 candidate(s) being considered.
[INFO]
[INFO] Modifications:
[INFO]  Replacing field [ContactList model.SomeDomainEntity#contacts]
[INFO]  1 modification(s) to original code.
[INFO]
[INFO] Deletions:
[INFO]  Removing class model.ContactList from package model
[INFO]  Removing factory method [model.ContactList#createContactList()] from model.ObjectFactory
[INFO]  Removing factory method [javax.xml.bind.JAXBElement<model.ContactList>#createContacts()] from model.ObjectFactory
[INFO]  3 deletion(s) from original code.

Later when the service is compiled xew reports again but does not delete ContactList class:

[INFO] Compilation:
[INFO]   JAXB version         : 2.2.11
[INFO]   Control file         : <none>
[INFO]   Summary file         : <none>
[INFO]   Instantiation mode   : EARLY
[INFO]   Collection impl      : java.util.ArrayList
[INFO]   Collection interface : java.util.List
[INFO]   Plural form          : false
[INFO]
[INFO] Candidates:
[INFO]  [+]: model.ContactList
[INFO]  1 candidate(s) being considered.
[INFO]
[INFO] Modifications:
[INFO]  0 modification(s) to original code.
[INFO]
[INFO] Deletions:
[INFO]  0 deletion(s) from original code.

Would you be able to tell me why xew does not execute the removal of the class 2nd time around?

Generating Classes for cXML DTD

Hello dmak.

I desperately need to generate Java classes by using cXML DTD.

I have tried the command line client but I am running into this error.

[ERROR] Property "Name" is already defined. Use &lt;jaxb:property> to resolve this conflict.
  line 489 of file:/C:/STPL%20Stuff/DTD2Java/cXML.dtd

[ERROR] The following location is relevant to the above error
  line 487 of file:/C:/STPL%20Stuff/DTD2Java/cXML.dtd

Failed to parse a schema.

I know this is totally doable, but my organization policies does not allow me to spend time on learning the awesome stuff you have made ๐Ÿ˜ข

Can you help with my trouble?

The cXML DTD could be found here.

Gradle, Ant, and CLI build fail with "Provider com.sun.tools.xjc.addon.xew.XmlElementWrapperPlugin not a subtype"

Just so it's clear, I don't think this is a real issue with your code. I can demonstrate the error using your extension, but I can demonstrate the same error without your code. Perhaps you're familiar with this issue and might have some advice on how to fix this.

I've initially configured a Gradle build referencing this extension using the Ant XJC task. I also did the same with an Ant build script, along with a simple Bash script calling the XJCFacade class directly.

All of these fail with this:

Exception in thread "main" java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: Provider com.sun.tools.xjc.addon.xew.XmlElementWrapperPlugin not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:231)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
    at com.sun.tools.xjc.Options.findServices(Options.java:957)
    at com.sun.tools.xjc.Options.getAllPlugins(Options.java:374)
    at com.sun.tools.xjc.Options.parseArgument(Options.java:688)
    at com.sun.tools.xjc.Driver$OptionsEx.parseArgument(Driver.java:511)
    at com.sun.tools.xjc.Options.parseArguments(Options.java:809)
    at com.sun.tools.xjc.Driver.run(Driver.java:240)
    at com.sun.tools.xjc.Driver.run(Driver.java:200)
    at com.sun.tools.xjc.Driver._main(Driver.java:123)
    at com.sun.tools.xjc.Driver.access$000(Driver.java:80)
    at com.sun.tools.xjc.Driver$1.run(Driver.java:103)

Although I get this error using this plugin, I don't think this is a particular issue with your plugin, because I see the same symptom with every other JAXB extension I've tried to use.

However, if I run the build using the "cxf-xjc-plugin" in Maven, I do not have this problem. I'm trying to convert this build from Maven to Gradle, so I need to fix this problem.

I'm running my builds with JDK 7, and I'm currently using version 2.2.6 of the JAXB api, impl, and xjc jars.

Duplicate setters generated when using xew plugin along with setters flag of the JAXB2 basics plugin

I'm having this issue when using the xew-plugin along with the JAXB2 Basics plugin. Consider the following XSD:

  <complexType name="A">
    <sequence>
      <element name="b" type="tns:B" minOccurs="0" maxOccurs="1"/>
    </sequence>
  </complexType>

  <complexType name="B">
    <sequence>
      <element name="c" type="string" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
  </complexType>

Now, when I configure my JAXB plugin with Maven like this:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.8.1</version>
    <executions>
        <execution>
            <id>configuration</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <forceRegenerate>true</forceRegenerate>
                <extension>true</extension>
                <strict>false</strict>
                <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                <bindingDirectory>src/main/resources/xjb</bindingDirectory>
                <schemaIncludes>
                    <include>jooq-codegen-3.3.0.xsd</include>
                </schemaIncludes>
                <generatePackage>org.jooq.util.jaxb</generatePackage>
                <args>
                    <arg>-Xxew</arg>
                    <arg>-Xxew:delete</arg>
                    <arg>-Xsetters</arg>
                </args>
                <plugins>
                    <plugin>
                        <groupId>com.github.jaxb-xew-plugin</groupId>
                        <artifactId>jaxb-xew-plugin</artifactId>
                        <version>1.0</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>0.6.5</version>
                    </plugin>           
                </plugins>
            </configuration>
        </execution>
    </executions>
</plugin>

I then get the following, invalid output:

    @XmlElementWrapper(name = "b")
    @XmlElement(name = "c")
    protected List<String> b = new ArrayList<String>();

    public List<String> getB() {
        return b;
    }

    public void setB(List<String> b) {
        this.b = b;
    }

    public void setB(List<String> value) {
        this.b = null;
        this.setB(value);
    }

The first setter being generated by xew, the second setter by setters.


A possible solution would be to add a flag to avoid the generation of setters...

Anonymous choice types with unbounded maxOccurs are completely removed from the model

If we modify the example schema to use a choice with anonymous types, the plugin generates code that won't compile:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

  <xsd:element name="order">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="items" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="items">
    <xsd:complexType>
      <xsd:choice maxOccurs="unbounded">
        <xsd:element name="itemOfTypeA">
          <xsd:complexType>
            <xsd:attribute name="something" type="xsd:string" />
          </xsd:complexType>
        </xsd:element>
        <xsd:element name="itemOfTypeB">
          <xsd:complexType>
            <xsd:attribute name="somethingElse" type="xsd:string" />
          </xsd:complexType>
        </xsd:element>
      </xsd:choice>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Enabling the xew plugin generates the following code, which doesn't compile because the Items class was removed.

public class Order {

    @XmlElementWrapper(required = true)
    @XmlElements({
        @XmlElement(name = "itemOfTypeA", type = generated.Items.ItemOfTypeA.class),
        @XmlElement(name = "itemOfTypeB", type = generated.Items.ItemOfTypeB.class)
    })
    protected List<Object> items = new ArrayList<Object>();
}

too verbose logging

Since few version the loggings are too verbose (Replacing field, Removing ...)

ComplexType consisting only of sequence results in empty object

<xs:complexType name="notifyResponse"> 
  <xs:sequence>
   <xs:element name="return" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:complexType>

will generate this code

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

@XmlAccessorType(XmlAccessType.FIELD)
public class NotifyResponse {
}

What it should generate is this

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "notifyResponse", propOrder = {
"_return"
 })
public class NotifyResponse {

 @XmlElement(name = "return")
 protected List<String> _return;
}

NoSuchFieldError with jaxws-maven-plugin

I can't get the jaxb-xew-plugin to work with maven version 3.2.1 and jaxws-maven-plugin version 2.3.

All I get is

Exception in thread "main" java.lang.ClassCastException: java.lang.NoSuchFieldError cannot be cast to java.lang.Exception
at org.jvnet.jax_ws_commons.jaxws.Invoker.main(Invoker.java:87)

Any ideas?
kermit-the-frog

Not seeing my collection type produced.

My Issue

My goal is to set a list type element in my XSD, such as LinkedList. Long term, my plan is to use my own custom list type, but for now, I am trying to override the default ArrayList type.

I am using this plugin (version 1.10). Here is my relevant code:

XSD:

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema jaxb:version="2.0"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xew="http://github.com/jaxb-xew-plugin"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           jaxb:extensionBindingPrefixes="xew"
           elementFormDefault="qualified">

    <xs:element name="TEST">
        <xs:complexType>
            <xs:annotation>
                <xs:appinfo>
                    <xew:xew collection="java.util.LinkedList"
                             collectionInterface="java.util.List"
                             instantiate="lazy"
                             plural="true"/>
                </xs:appinfo>
            </xs:annotation>
            <xs:choice>
                <xs:element name="action" type="xs:token" minOccurs="0" maxOccurs="unbounded">
                </xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>

</xs:schema>

POM:

    <build>
        <resources>
            <resource>
                <directory>src/main/xsd</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>2.5.0</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <configuration>
                            <sources>src/main/xsd</sources>
                            <packageName>com.tug.data.model.gen</packageName>
                            <verbose>true</verbose>
                            <clearOutputDir>false</clearOutputDir>
                            <extension>true</extension>
                            <arguments>
                                <argument>-Xsetters</argument>
                                <argument>-Xxew</argument>
                                <argument>-Xfluent-api</argument>
                                <argument>-Xjaxbindex</argument>
                                <argument>-Xequals</argument>
                                <argument>-XhashCode</argument>
                                <argument>-XtoString</argument>
                                <argument>-Xcopyable</argument>
                                <argument>-Xmergeable</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.github.jaxb-xew-plugin</groupId>
                        <artifactId>jaxb-xew-plugin</artifactId>
                        <version>1.10</version>
                    </dependency>
                    <dependency>
                        <groupId>net.java.dev.jaxb2-commons</groupId>
                        <artifactId>jaxb-fluent-api</artifactId>
                        <version>2.1.8</version>
                    </dependency>
                    <dependency>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>0.12.0</version>
                    </dependency>
                </dependencies>
            </plugin>

Resulting Java code generated

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "action"
})
@XmlRootElement(name = "TEST")
public class TEST implements Cloneable, CopyTo2, Equals2, HashCode2, MergeFrom2, ToString2
{

    @XmlElement(required = true)
    protected List<Action> action;

    public List<Action> getAction() {
        if (action == null) {
            action = new ArrayList<Action>(); // <--- **This should have been LinkedList**
        }
        return this.action;
    }

As you can see, the ArrayList type is still coming out. It actually seems like the xew are being ignored entirely... I don't get any errors

I have tried many variations of this, copying and pasting the xs:annotation blurb pretty much in every combination of locations I could logically think of. The only error I get is here:

    <xs:element name="TEST">
        <xs:complexType>
            <xs:choice>
                <xs:element name="action" type="xs:token" minOccurs="0" maxOccurs="unbounded">
                    <xs:annotation>
                        <xs:appinfo>
                            <xew:xew collection="java.util.LinkedList"
                                     collectionInterface="java.util.List"
                                     instantiate="lazy"
                                     plural="true"/>
                        </xs:appinfo>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>

This combo results in: com.sun.istack.SAXParseException2: compiler was unable to honor this xew customization. It is attached to a wrong place, or its inconsistent with other bindings.

Do you see any missing step which would result in my custom collection override would not be picked up on?

I attached the maven debug output, it is a lot to look through and I don't pick up any hints there.
mvn-debug.log

Support JAXB2.1

I made changes to this plugin and now it works with jaxb2.1.
I want to send you changes but I can't find your email.

Excludes file when using Plural

Would be cool if we could feed the plugin an "excludes file" which it would use as a preference when generating the plural form. Sometimes the plural function results in words like travelerIDReves or priceClassDatas.

Or thinking about it, an extendable catalog that contains regexp patterns of how to map to plural could also do the trick?

xsd:complexType mixed="true" does not read mixed content from xml

This issue appears to be related to this discussion about JAXB MixedMode on stackoverflow

The XML Schema (below) has two complexTypes (ArgumentType) and (Argument) both using mixed="true". Using XJC, everything works as expected; however using the jaxb-xew-plugin, the content is not unmarshalled/loaded from the xml document.

I have not yet found a workaround.

Here's my XML Schema illustrating the issue:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="https://github.com/dmak/jaxb-xew-plugin/schema/xew-test" 
    xmlns:tns="https://github.com/dmak/jaxb-xew-plugin/schema/xew-test" 
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"  jaxb:extensionBindingPrefixes="xjc"
    elementFormDefault="qualified">
    <xs:annotation>
        <xs:appinfo>
            <jaxb:globalBindings>
                <xjc:simple />
            </jaxb:globalBindings>
        </xs:appinfo>
    </xs:annotation>
    <xs:element name="program" type="tns:Program"/>

    <xs:complexType name="Program">
        <xs:sequence minOccurs="0" maxOccurs="1">
            <xs:element name="argument" >
                <xs:complexType mixed="true">
                    <xs:sequence minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="file" type="tns:PlainFilename"/>
                    </xs:sequence>
                </xs:complexType>           
            </xs:element>
            <xs:element name="argument-type" type="tns:ArgumentType"/>
        </xs:sequence>
    </xs:complexType>   

    <xs:complexType name="ArgumentType" mixed="true">
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="at-file" type="tns:PlainFilename"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="PlainFilename">
        <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>

</schema>

When I compile the code without the jaxb-xew-plugin (e.g., using XJC), the Argument and ArgumentType mixed content is returned after I marshall/unmarshall the content to an XML file.

        \\ initialize Program class
    JAXBContext context = JAXBContext.newInstance(Program.class);
        Marshaller marshaller = context.createMarshaller();
        StringWriter writer = new StringWriter();
        marshaller.marshal(prog, writer);
        System.out.println(writer.toString());

<program xmlns="https://github.com/dmak/jaxb-xew-plugin/schema/xew-test"><argument>-o<file name="filename"/></argument><argument-type>-i<at-file name="filename"/></argument-type></program>

        Unmarshaller unmarshaller = context.createUnmarshaller();
        StringReader reader = new StringReader(writer.toString());
        Program progIn = (Program) unmarshaller.unmarshal(reader);

        writer = new StringWriter();
        marshaller.marshal(progIn, writer);
        System.out.println(writer.toString());  

<program xmlns="https://github.com/dmak/jaxb-xew-plugin/schema/xew-test"><argument>-o<file name="filename"/></argument><argument-type>-i<at-file name="filename"/></argument-type></program>

Using the exact same XML schema and code generated with the jaxb-xew-plugin, the mixed content is lost during unmarshalling:

        \\ initialize Program class
    JAXBContext context = JAXBContext.newInstance(Program.class);
        Marshaller marshaller = context.createMarshaller();
        StringWriter writer = new StringWriter();
        marshaller.marshal(prog, writer);
        System.out.println(writer.toString());

<program xmlns="https://github.com/dmak/jaxb-xew-plugin/schema/xew-test"><argument>-o<file name="filename"/></argument><argument-type>-i<at-file name="filename"/></argument-type></program>

        Unmarshaller unmarshaller = context.createUnmarshaller();
        StringReader reader = new StringReader(writer.toString());
        Program progIn = (Program) unmarshaller.unmarshal(reader);

        writer = new StringWriter();
        marshaller.marshal(progIn, writer);
        System.out.println(writer.toString());  

<program xmlns="https://github.com/dmak/jaxb-xew-plugin/schema/xew-test"><argument/><argument-type/></program>

Here, with Xew, both Argument and ArgumentType are empty after unmarshalling.

-Xjaxbindex plugin from JAXB commons does not work with the xew plugin

I recently added -Xjaxbindex to the xjc schema compiler and noticed that the generated jaxb.index file still contains the public wrapper classes that xew discharges. A quick look in the jaxb index plugin source suggest around line 28 that it is using the overall xjc outline that is passed through the plugins. I did add the -Xjaxbindex arg after the -Xxew arg in the XJC compiler but it seems xew is not removing the classes it deletes in the generated code from the outline, hence the jaxb index plugin producing a wrong index file.

That's how jaxb index plugin decides what goes into the jaxb.index file:

for (final ClassOutline classOutline : packageOutline.getClasses()) {
...
}

Is that hard to fix?

No code changes happen under cxf-codegen-plugin

I tried to use this plugin with the cxf-codegen-plugin to improve the output from code generated from XSD inside of a WSDL. When using -Dorg.apache.commons.logging.simplelog.defaultlog=DEBUG, I see a huge number of actions about replacing fields and deleting classes and object factory methods, and they are all of the ones I'd like to remove, too. But the resulting Java source code is not modified in any way I can detect and the "removed" classes and methods still exist. I don't understand because the logging output is so extensive that something is happening but I see no impact from the result.

I run Maven with mvn -Dorg.apache.commons.logging.simplelog.defaultlog=DEBUG clean compile

The Maven plugin config is below. Some notes:

  • I had to exclude wstx-asl to remove conflict with Woodstox 4.2.0 parser which has a different artifactId.
  • I tried adding the jaxb-xjc dependency of 2.2.4-1 from the xew wiki page just in case, but the result is the same.
  • I never got the -Xxew:summary to work with any file path, but the debug log output seems to have the information I needed.
<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-client</id>
            <phase>generate-sources</phase>
            <configuration>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdlArtifact>
                            <groupId>com.example</groupId>
                            <artifactId>api</artifactId>
                            <version>${project.version}</version>
                            <type>wsdl</type>
                        </wsdlArtifact>
                        <extraargs>
                            <!--<extraarg>-client</extraarg>-->
                            <extraarg>-xjc-Xxew</extraarg>
                            <!--<extraarg>-xjc-Xxew:summary summary</extraarg>-->
                            <!--<extraarg>-xjc-Xxew:instantiate lazy</extraarg>-->
                            <extraarg>-xjc-Xxew:delete</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>com.github.jaxb-xew-plugin</groupId>
            <artifactId>jaxb-xew-plugin</artifactId>
            <version>1.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.woodstox</groupId>
                    <artifactId>wstx-asl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</plugin>

ObjectFactory does not compile because of incompatible generic Types

Long story short following line
return new JAXBElement<List<String>>(new QName("http://interface.deskline.net/DSI/XSD", "Item"), List.class, SearchParametersType.class, value);

must be written as
return new JAXBElement<List<String>>(new QName("http://interface.deskline.net/DSI/XSD", "Item"), ((Class)List.class), SearchParametersType.class, value);

or the code does not compile with error ObjectFactory.java:[4241,110] incompatible types: java.lang.Class<java.util.List> cannot be converted to java.lang.Class<java.util.List<java.lang.String>>

I am using Java 8, JAXB 2.3.0 and jaxb2-maven-plugin:2.4

Issue with namespaces in case of unqualified schema

Originally reported in issue#21 by @valsoray17:

[TestSchema]

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="testNamespace"
           targetNamespace="testNamespace" elementFormDefault="unqualified"
           attributeFormDefault="unqualified">

    <xs:element name="element1" type="ElementType1">
        <xs:annotation>
            <xs:documentation>Root element</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:complexType name="ElementType1">
        <xs:sequence>
            <xs:element name="stringList" type="stringListType" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="stringListType">
        <xs:sequence>
            <xs:element name="listItem" type="xs:string" minOccurs="0"
                        maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

</xs:schema>

[TestXml.xml]

<?xml version="1.0" encoding="UTF-8"?>
<n:element1 xmlns:n="testNamespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <stringList>
        <listItem>str1</listItem>
        <listItem>str2</listItem>
        <listItem>str3</listItem>
        <listItem>str4</listItem>
    </stringList>
</n:element1>

The generated code defines namespace = "testNamespace":

@XmlElement(name = "listItem", namespace = "testNamespace")
protected List<String> stringList;

In this case the list is empty after unmarshaling. If the namespace is removed from the annotation then the list contains data.
I know that schema is not correct, but still valid and I don't have possibility to fix it.

Compatibility with Jaxb xjc v3.0.0

Hi,

I have a kotlin ktor project that generates code from xsd using jaxb xjc. I have a few plugin such as xew. I have upgraded xjc today to version 3.0.0.

And after the upgrade, I have an issue in the plugin xew (please find bellow the stacktrace).
Obviously if I downgrade back to xjc 2.3.3, there is no issue during the build.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateCatalogSources'.
> 'void com.sun.tools.xjc.model.CElementPropertyInfo.<init>(java.lang.String, com.sun.tools.xjc.model.CElementPropertyInfo$CollectionMode, com.sun.xml.bind.v2.model.core.ID, javax.activation.MimeType, com.sun.xml.xsom.XSComponent, com.sun.tools.xjc.model.CCustomizations, org.xml.sax.Locator, boolean)'

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':generateCatalogSources'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:200)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:198)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:179)
        at ...
Caused by: java.lang.NoSuchMethodError: 'void com.sun.tools.xjc.model.CElementPropertyInfo.<init>(java.lang.String, com.sun.tools.xjc.model.CElementPropertyInfo$CollectionMode, com.sun.xml.bind.v2.model.core.ID, javax.activation.MimeType, com.sun.xml.xsom.XSComponent, com.sun.tools.xjc.model.CCustomizations, org.xml.sax.Locator, boolean)'
        at com.sun.tools.xjc.addon.xew.XmlElementWrapperPlugin.runInternal(XmlElementWrapperPlugin.java:451)
        at com.sun.tools.xjc.addon.xew.config.AbstractConfigurablePlugin.run(AbstractConfigurablePlugin.java:263)
        at com.sun.tools.xjc.model.Model.generateCode(Model.java:262)
        at com.sun.tools.xjc.Driver.run(Driver.java:354)
        at com.sun.tools.xjc.Driver.run(Driver.java:191)
        at Build_gradle$generateCatalogSourcesFunction$1.execute(build.gradle.kts:326)
...

Do you plan to upgrade the plugin to support xjc 3.0.0 ?

This is an extract of my build.gradle.kts

fun generateCatalogSourcesFunction(
    task: Task,
    catalog: CatalogType,
    generateNullableAnnotations: Boolean = true
) {
    task.description = "Generates Catalog sources from xsd."

    val packageName = catalog.toPackage()
    val inputDir = "$projectDir/src/main/resources/catalog/${catalog.toXsdFileName()}"
    val outputDir = "$buildDir/generated-sources/models/catalog/"

    task.inputs.file(inputDir)
    task.outputs.dir(outputDir)

    val args = listOfNotNull(
        "-d", outputDir,
        "-p", packageName,
        "-encoding", "UTF-8",
        "-no-header",
        "-Xxew",
        if (generateNullableAnnotations) "-XNullable" else null, // respecter l'ordre d'abord nullable puis toString
        "-XToStringHashCodeEquals", // laisser comme รงa le temps que l'issue soit corrigรฉe.
        inputDir
    )

    task.doLast {
        Driver.run(args.toTypedArray(), System.out, System.out)
    }
}

XSD:ANY generates uncompilable code

<element name="Data" minOccurs="0">
    <complexType>
        <sequence>
            <any minOccurs="0" maxOccurs="unbounded" />
        </sequence>
    </complexType>
</element>

Becomes

@XmlElementWrapper(name = "Data")
@XmlElement(name = "any")
protected List<Object> data;

But should be

@XmlElement(name = "Data")
protected List<Object> data;

Usage with jaxb2-maven-plugin

The readme suggests to configure the Codehaus jaxb2-maven-plugin with
<arguments>-no-header -Xxew -Xxew:instantiate lazy</arguments>
which did not work for me (version 2.4).

Instead I had to do this:

<arguments>
    <argument>-Xxew</argument>
    <argument>-Xxew:instantiate lazy</argument>
</arguments>

JDK11 Compatibility? JAXB > 2.3.x?

Hi,

I've been using this plugin in my jaxb projects and wondered if there was going to be an upgraded version to support 2.3.x JAXB and JDK11.

When using your plugin in a gradle build on JDK11 release I get a few warnings I have managed to track down to your plugin.

Errors occurred while build effective model from /Users/michaelbennet/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-core/2.2.11/db0f76866c6b1e50084e03ee8cf9ce6b19becdb3/jaxb-core-2.2.11.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-core:2.2.11

I think its to do with your dependency on jaxb but it could also be your use of the ${tools.jar} element in your maven script that is being added to overall dependency tree possibly?

Tools.jar has been removed in JDK 11 so another option/solution may be needed.

Classes are generated but not with List from Gradle

buildscript{
    repositories{
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'no.nils:wsdl2java:0.10'
    }
}

plugins {
	id "com.intershop.gradle.jaxb" version "3.0.0"
	id 'org.springframework.boot' version '2.1.4.RELEASE'
	id 'java'
	id 'eclipse'
	id 'jacoco'
	id "org.sonarqube" version "2.7"
}

apply plugin: 'no.nils.wsdl2java'
apply plugin: 'io.spring.dependency-management'

group = 'com.company.data.pumps'
sourceCompatibility = '1.8'

project.ext {
    jaxbVersion = "2.2.11"
    generatedSourcesDir = "target/classes/generated"
}

sourceSets {
    generated {
        output.dir(generatedSourcesDir)
        java {
            srcDir project.generatedSourcesDir
        }
    }
    main.java.srcDirs = [generatedSourcesDir, 'src/main/java']
    test {
        compileClasspath += generated.output
        runtimeClasspath += generated.output
    }
}

repositories {
	mavenCentral()
	jcenter()
	maven { url "http://mpv-jenkins05:8081/artifactory/ext-release-local"}
}

configurations {
    xjc
}

dependencies {
	compile "com.sun.xml.bind:jaxb-xjc:${jaxbVersion}"
    compile "com.sun.xml.bind:jaxb-core:${jaxbVersion}"
    compile "com.sun.xml.bind:jaxb-impl:${jaxbVersion}"
    compile "javax.xml.bind:jaxb-api:${jaxbVersion}"
    compile "javax.activation:activation:1.1"

    xjc "com.github.jaxb-xew-plugin:jaxb-xew-plugin:1.10"
    xjc "net.java.dev.jaxb2-commons:jaxb-fluent-api:2.1.8"
    
	implementation 'org.springframework.boot:spring-boot-starter'
	implementation 'javax.validation:validation-api:2.0.1.Final' // Domain object validation
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.8' //Jackson to Convert from RabbitMQ to ECDRequest
    implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
    implementation 'org.apache.commons:commons-text:1.6'
    implementation 'org.springframework.ws:spring-ws-core:3.0.7.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-amqp' // Rabbit MQ
    implementation ('org.springframework.boot:spring-boot-starter-data-jpa') { // JPA (Hibernate)
    	exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc' 
    } 
    implementation 'com.oracle:ojdbc7:12.1.0.1.0'
    implementation 'com.zaxxer:HikariCP:3.2.0'
    
    testCompile 'org.springframework.boot:spring-boot-starter-test'
    testCompile 'com.github.fridujo:rabbitmq-mock:1.0.10' // RabbitMQ Test
    testCompile 'com.github.fridujo:spring-automocker:1.1.0'
    testImplementation(enforcedPlatform("org.junit:junit-bom:5.4.1")) // JUnit 5 BOM
    testImplementation 'org.skyscreamer:jsonassert:1.5.0'
	testImplementation 'net.javacrumbs.json-unit:json-unit:2.4.0'
	testImplementation 'org.junit.jupiter:junit-jupiter'
	testImplementation 'org.junit.jupiter:junit-jupiter-params'
    testImplementation 'org.junit.jupiter:junit-jupiter-api'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
    testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}

// GENERATE TRILLIUM FILES 
// Run in cmd > gradlew generateTrilllium
// Don't use deleteGeneratedSource task, remove them manually if needed
//
def trilliumGenFolder = "${projectDir}/src/main/java"
def trilliumPackage = 'com.company.data.pumps.infrastructure.trillium.soap'

wsdl2java {
    encoding = 'utf-8'
    wsdlsToGenerate = [
            ['-p', trilliumPackage , '-autoNameResolution', "${projectDir}/src/main/resources/trillium/trillium.wsdl"]
    ]
    generatedWsdlDir = file(trilliumGenFolder)
    wsdlDir = file("${projectDir}/src/main/resources/trillium")
}

/** ECD DTO - GENERATE JAVA CLASSES FROM XSD **/
task processXSD {
	description = 'Generates Java Classes from XSD fro ECDRquest message sent from RabbitMQ'
	group = 'jaxb code generation'
	
    ant.taskdef(name: "xjc", classname: "com.sun.tools.xjc.XJCTask", classpath: configurations.compile.asPath)

    mkdir project.generatedSourcesDir
    ant.xjc(destdir: project.generatedSourcesDir, package: "com.company.data.pumps.infrastructure.rabbitmq", extension: true) {
        classpath {
            pathelement(path: configurations.xjc.asPath)
        }
        schema(dir: "src/main/resources/ecd", includes: "ECDRequest.xsd")
        arg(value: "-Xxew")
        arg(value: "-Xfluent-api")
    }
}
compileJava.dependsOn processXSD

/**UNIT TESTS**/
test {
    useJUnitPlatform {
        excludeTags 'integration'
        includeEngines 'junit-jupiter', 'junit-vintage'
    }

    failFast = true
}

/**INTEGRATION TESTS**/
task integrationTests (type: Test){
	description = 'Runs Integrations Tests'
	group = 'verification'
	useJUnitPlatform {
        includeEngines 'junit-jupiter', 'junit-vintage'
    }

    failFast = true
}


/** JACOCO - CODE COVERAGE **/
def jacocoReportPath = "${buildDir}/jacocoHtml"
jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.destination file(jacocoReportPath)
    }
}

/** SONARQUBE - CODE STATIC ANALYSIS**/
sonarqube {
	properties {
		property "sonar.jacoco.reportPaths", jacocoReportPath
		property "sonar.projectKey", "ecd-feeder"  
		property "sonar.buildbreaker.skip" , "false"
		property "sonar.test.inclusions", "**src/test/java**"
		property "sonar.jacoco.reportPaths", "build/jacoco/unitTest.exec,build/jacoco/integrationTest.exec"
	}
}
project.tasks["sonarqube"].dependsOn jacocoTestReport

Refs of Sequences from different namespace are not deleted from Factory class

You create a type that is a possible type for removal. This type belongs to the first namespace.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/FirstNamespace" 
			xmlns="http://www.example.org/FirstNamespace" elementFormDefault="qualified">

	
	<xs:complexType name="Booleans">
		<xs:sequence>
			<xs:element name="BooleanValue" type="xs:boolean" minOccurs="0" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>


</xs:schema>

You create a second namespace that imports the first namespace and creates an element of this type.
This element is referenced by another type.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 	xmlns:xs="http://www.w3.org/2001/XMLSchema" 
			targetNamespace="http://www.example.org/SecondNamespace" 
			xmlns="http://www.example.org/SecondNamespace"
			xmlns:first="http://www.example.org/FirstNamespace"
			elementFormDefault="qualified">

	<xs:import namespace="http://www.example.org/FirstNamespace" schemaLocation="FirstNamespace.xsd" />

	<xs:complexType name="SomeType">
		<xs:sequence>
			<xs:element ref="MyBooleanList" />
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="MyBooleanList" type="first:Booleans"/>
		
</xs:schema>

With this setup the created Factory class expects the deleted class.

package org.example.secondnamespace;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
import org.example.firstnamespace.Booleans;


/**
 * This object contains factory methods for each 
 * Java content interface and Java element interface 
 * generated in the org.example.secondnamespace package. 
 * <p>An ObjectFactory allows you to programatically 
 * construct new instances of the Java representation 
 * for XML content. The Java representation of XML 
 * content can consist of schema derived interfaces 
 * and classes representing the binding of schema 
 * type definitions, element declarations and model 
 * groups.  Factory methods for each of these are 
 * provided in this class.
 * 
 */
@XmlRegistry
public class ObjectFactory {

    private final static QName _MyBooleanList_QNAME = new QName("http://www.example.org/SecondNamespace", "MyBooleanList");

    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.example.secondnamespace
     * 
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link SomeType }
     * 
     */
    public SomeType createSomeType() {
        return new SomeType();
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link Booleans }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://www.example.org/SecondNamespace", name = "MyBooleanList")
    public JAXBElement<Booleans> createMyBooleanList(Booleans value) {
        return new JAXBElement<Booleans>(_MyBooleanList_QNAME, Booleans.class, null, value);
    }

}

Calling xew from command line fails with "unrecognized parameter -Xxew"

As an attempt to get more information for my other issue ("Provider xx not a subtype"), I'm trying to run xjc directly from the command line, specifying the same options I'm trying to use in the build.

I'm using the xjc from the JDK, (7 or 8) and attempting the following command line:

xjc -extension  -classpath "lib/jaxb-fluent-api-2.1.8.jar;lib/jaxb-xew-plugin-1.4.jar" -Xxew -summary target/xew-summary.txt -instantiate lazy -Xfluent-api schema/serviceCallResults.xsd

This fails with "unrecognized parameter -Xxew" and then gives me the "usage" page.

What am I missing?

Problem with different Namespaces and Wrapped Element

Hello, If an element in a namspace imports a complextype from an other namespace, which only include one element unbounded ( a List), the namespace in the generated Class for the wrapped item element is missing / wrong. See also Issue #8 .
Example:

[test.xsd / testnamespace]
<xs:element name="notes" type="com:WsNotes" minOccurs="0" />

[com:xsd / common namespace]
<xs:complexType name="WsNotes"> <xs:sequence> <xs:element name="note" type="com:WsNote" minOccurs="0" maxOccurs="unbounded"> </xs:element> </xs:sequence> </xs:complexType>

Generated Class:

@XmlElementWrapper(name = "notes") @XmlElement(name = "note") // Namesspace common (com) is missing! protected List<WsNote> notes;

ciao Renรฉ

Generating with duplicate name in different wsdl files

Hey again,
I'm trying to generate the wsclient in the same directory with different wsdl's
The only problem is now that there are duplicate names.
In my example there is in test.wsdl the string2string2ArrayOfStringMapMap which has entries and a string2ArrayOfStringMap which has a different entry but with the same name, this all generating well.
The is an Entry.java which has List<String2ArrayOfStringMapEntry> and there is an String2ArrayOfStringMapEntry which has List<String> thats all correct but when I now generating the wsdl file with the second wsdl which doesn't have string2string2ArrayOfStringMapMap.
Its generating Entry.java again but then instead of List<String2ArrayOfStringMapEntry> with List<String> which will make String2ArrayOfStringMapEntry == Entry so the *Entry with List<String2ArrayOfStringMapEntry> is missing because the old Entry got overwritten.
Without the xew plugin it generates the entry String2ArrayOfStringMap.Entry or String2string2ArrayOfStringMapMap.Entry so I guess this is because of xew.

So is there the possibility to not generate Entry but rather generate for String2ArrayOfStringMap.Entry String2ArrayOfStringMapEntry and so on that there is no single Entry class?

https://github.com/jmattheis/jaxb-xew-plugin/tree/master/samples/cxf-codegen-plugin-other

EDIT: The String2*Map have as key String and in my text I'm mean the value

Plugin does not work when generateValueClass is set to false

Thanks for the extension but I have a problem when xjc is set to generate interfaces i.e. (generateValueClass="false").

This is because the evaluation of the candidate does not recognise the interface.

I've a hack that fixes it but which I'll attach to the issue.

I had to use boxify a couple of times to check for assignable but it seems to work (I haven't checked it without interfaces)

Doesn't seem to work without jaxb-impl

Hey,

Thanks for creating this plugin, it's exactly what I needed today! Just raising this issue as I followed the Gradle instructions in the readme but got the following error:

Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
com.sun.xml.bind.api.impl.NameConverter is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
                                             at com.sun.xml.bind.api.impl.NameConverter
at public com.sun.xml.bind.api.impl.NameConverter com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.nameConverter
at com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding

Managed to resolve this by adding the JAXB impl dependency to my compile scope e.g.
compile 'com.sun.xml.bind:jaxb-impl:2.2.7'

Wasn't sure if this was something just happening to me locally or if it's an omission in the docs.

Thanks again!

Edd

Duplicate 'create...' methods are generated in ObjectFactory

Hi!

Processing of the following schema fragment produces duplicate createDemoXewBugActionItem() method in the ObjectFactory class:

<xs:element name="DemoXewBug">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="Action">
        <xs:complexType>
          <xs:choice>
            <xs:element name="UpdateSomeItems">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                      <xs:all>
                        <xs:element name="Key" type="xs:string"/>
                        <xs:element name="Value" type="xs:string"/>
                      </xs:all>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="UpdateOtherItems">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                      <xs:all>
                        <xs:element name="Key" type="xs:string"/>
                        <xs:element name="Value" type="xs:string"/>
                      </xs:all>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:choice>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

I think that happens because XmlElementWrapperPlugin.renameFactoryMethod does not check for existence of the new method prior to renaming.

Unwrapped ListWrapper inside *PortType

Some time ago, I asked a question on Stackoverflow, there someone said to me that Do you want UserManagementPortType.getAllUsers to directly return a List<User> instead? That might not be possible, Could you verify this, that it is not possible to return a List<X> or have a List<X> inside the *PortType methode's.
Currently I have this jaxws binding which put the request and response in an extra object

<jaxws:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
            xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
            xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
    <jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>

With this, it works, but in does not look very nice inside the code.
http://stackoverflow.com/questions/33667462/cxf-wsdl2java-listwrapper-in-wsdl-should-be-unwrapped#comment55540572_33887005

jaxb2-basic hashCode() and equals() still uses removed classes

The jaxb2-basic which adds hashCode() with -xjc-XhashCode and equals() with -xjc-Xequals still uses classes which were removed by xew, is there support for this or does the xew plugin not support other plugins?
groupId: org.jvnet.jaxb2_commons
artifactId: jaxb2-basics

Element inheritance via substitution groups is broken

I have adopted the example from http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html by allowing multiple contact info elements and adding a wrapper element around them.

Here's my XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
    version="1.0"
    jxb:version="2.1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    >

    <xs:element name="customer" type="customerType" />
    <xs:element name="contact-info" type="contactInfoType" abstract="true"/>
    <xs:element name="address" type="addressType" substitutionGroup="contact-info" />
    <xs:element name="phone-number" type="phoneNumberType" substitutionGroup="contact-info" />

    <xs:complexType name="customerType">
        <xs:annotation>
            <xs:appinfo>
                <jxb:class name="Customer"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="contact-infos" minOccurs="0">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element ref="contact-info" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="contactInfoType" abstract="true">
        <xs:annotation>
            <xs:appinfo>
                <jxb:class name="ContactInfo"/>
            </xs:appinfo>
        </xs:annotation>
    </xs:complexType>

    <xs:complexType name="addressType">
        <xs:annotation>
            <xs:appinfo>
                <jxb:class name="Address"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="contactInfoType">
                <xs:sequence>
                    <xs:element name="street" type="xs:string"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="phoneNumberType">
        <xs:annotation>
            <xs:appinfo>
                <jxb:class name="PhoneNumber"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="contactInfoType">
                <xs:sequence>
                    <xs:element name="area-number" type="xs:string"/>
                    <xs:element name="phone-number" type="xs:string"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:annotation>
        <xs:appinfo>
            <jxb:schemaBindings>
                <jxb:package name="test.xml"/>
            </jxb:schemaBindings>
        </xs:appinfo>
    </xs:annotation>

</xs:schema>

The resulting XML should look like that:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customer>
    <contact-infos>
        <address>
            <street>5th Avenue</street>
        </address>
        <phone-number>
            <area-number>010</area-number>
            <phone-number>1234567890</phone-number>
        </phone-number>
    </contact-infos>
</customer>

Without the xew plugin, I can marshall and unmarshall objects fine but the Java code looks ugly due to the implicite wrapper class.

customer.setContactInfos(new Customer.ContactInfos());
customer.getContactInfos().getContactInfo().add(factory.createAddress(address));
customer.getContactInfos().getContactInfo().add(factory.createPhoneNumber(phoneNumber));

When I enable the xew plugin, the Java code looks fine:

customer.getContactInfos().add(factory.createAddress(address));
customer.getContactInfos().add(factory.createPhoneNumber(phoneNumber));

Unfortunately the generated XML is invalid:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customer>
    <contact-infos>
        <contactInfo>
            <nil>false</nil>
            <value xsi:type="addressType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <street>5th Avenue</street>
            </value>
        </contactInfo>
        <contactInfo>
            <nil>false</nil>
            <value xsi:type="phoneNumberType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <area-number>010</area-number>
                <phone-number>1234567890</phone-number>
            </value>
        </contactInfo>
    </contact-infos>
</customer>

Visitor plugin doesn't work after xew

I tried to utilize visitor plugin after xew (-Xxew -Xxew:instantiate lazy -Xxew:delete -Xvisitor).

Visitor fails to generate proper traversers because it still sees the original XJC codemodel via Outline due to cached classes inside BeanGenerator that do not get refreshed when codemodel is changed.

At first glance this should propably be dealt at XJC level and I think that in the mean time the only thing xew could provide a workaround to this behaviour by mutilating the BeanGenerator cache via reflection simultaneously with codemodel changes.

Using plugin from Eclipse

Is it possible to use this plugin from within Eclipse when right clicking on a .wsdl file and using the "Generate Client" option? We have successfully used the plugin from a Maven project, but are finding it quite tedious to do so for every WSDL integration (the project we create to generate proxy objects is a throwaway after we generate the jar file).

I have created a binding file:

<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
	<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>

Then in Eclipse, I right click on the wsdl file to generate proxy objects:

image

I enable the option to specify a binding file:

image

And then select the binding file:

image

But my generated classes still contain the ArrayOfXxx objects.

Is there a way to accomplish it? I am currently using Eclipse 2021-06, j2ee version.

Thank you!

Intermediary classes still referenced

I have the following Schema:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xsd:element name="Foobar">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Ersteller" type="xsd:string"/>
                <xsd:element name="Files">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="File" maxOccurs="unbounded">
                                <xsd:complexType>
                                    <xsd:all>
                                        <xsd:element name="Name" type="xsd:string"/>
                                        <xsd:element name="Pruefsumme" type="xsd:string"/>
                                    </xsd:all>
                                </xsd:complexType>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
                <xsd:element name="Pruefsumme" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

and the plugin generates code:

...
@XmlElementWrapper(name = "Files", required = true)
@XmlElement(name = "File")
protected List<Foobar.Files.File> files;
...

But the "Files" class (and the "File") class are not generated.

Output (verbose) of the Maven run:

Compilation:
Date         :  -
Version      :  -
JAXB version :  2.2.5-2
Include file :  <none>
Exclude file :  <none>
Summary file :  <none>
Instantiate  :  LAZY
Collection   :  class java.util.ArrayList
Interface    :  interface java.util.List
Delete       :  true

Candidates:
[!]: (default): de.db.idis.poc.leidas.Foobar.Files
1 candidate(s) being considered.

Modifications:
de.db.idis.poc.leidas.Foobar#files  de.db.idis.poc.leidas.Foobar.Files
1 modification(s) to original code.

Deletions:
Removing method de.db.idis.poc.leidas.Foobar.Files createFoobarFiles from de.db.idis.poc.leidas.ObjectFactory
Removing class de.db.idis.poc.leidas.Foobar.Files from class de.db.idis.poc.leidas.Foobar
2 deletion(s) from original code.

Injection by setters

Please, add Instantiation type NONE.
It'll help to distinct the empty collection from absence of the collection(or null) in the soap request. This is why I use wrappers for collections.

NoSuchMethodException thrown with maven-jaxb2-plugin >= 0.12.2 and schema contains annotation

With a relatively simple schema compilation project, using jaxb-xew-plugin:1.7 with any version of maven-jaxb2-plugin greater than 0.12.1 results in the following stacktrace:

[INFO] Sources are not up-to-date, XJC will be executed.
java.lang.NoSuchMethodException: com.sun.xml.bind.v2.model.nav.ReflectionNavigator.getInstance()
    at java.lang.Class.getDeclaredMethod(Class.java:2130)
    at com.sun.xml.bind.v2.model.impl.Utils.<clinit>(Utils.java:71)
    at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:92)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:444)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:292)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:139)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1138)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:162)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationContext(BindInfo.java:336)
    at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationUnmarshaller(BindInfo.java:362)
    at com.sun.tools.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl$1.<init>(AnnotationParserFactoryImpl.java:85)
    at com.sun.tools.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl.create(AnnotationParserFactoryImpl.java:84)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.createAnnotationParser(NGCCRuntimeEx.java:365)
    at com.sun.xml.xsom.impl.parser.state.annotation.action0(annotation.java:88)
    at com.sun.xml.xsom.impl.parser.state.annotation.enterElement(annotation.java:113)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.NGCCHandler.spawnChildFromEnterElement(NGCCHandler.java:113)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:353)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.NGCCHandler.revertToParentFromEnterElement(NGCCHandler.java:150)
    at com.sun.xml.xsom.impl.parser.state.foreignAttributes.enterElement(foreignAttributes.java:90)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.NGCCHandler.spawnChildFromEnterElement(NGCCHandler.java:113)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:228)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:345)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:333)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:427)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:477)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:417)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:317)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.startElement(NGCCRuntime.java:258)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.util.SubtreeCutter.startElement(SubtreeCutter.java:108)
    at com.sun.tools.xjc.reader.ExtensionBindingChecker.startElement(ExtensionBindingChecker.java:150)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker.startElement(IncorrectNamespaceURIChecker.java:128)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.startElement(CustomizationContextChecker.java:193)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.startElement(DOMForestScanner.java:147)
    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244)
    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:281)
    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
    at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
    at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:92)
    at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:100)
    at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:104)
    at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:269)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:347)
    at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:128)
    at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:168)
    at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:157)
    at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:534)
    at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:378)
    at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
    at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:50)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:488)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:311)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

[...]
[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.2:generate (default) on project issue-50: Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.2:generate failed: An API incompatibility was encountered while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.2:generate: java.lang.ExceptionInInitializerError: null

xew fails with NPE when processing candidates that are base for substitution groups

The plugin fails with NPE when a base type is the list property but as such only abstract and base for a substitution group.

...
<xs:complexType name="Amount">
  <xs:sequence maxOccurs="2">
    <!-- this is the part that does not work -->
    <xs:element ref="foo:AmountOrPercentage"/>
  </xs:sequence>
</xs:complexType>
...

<xs:element name="AmountOrPercentage" abstract="true"/>

<xs:element name="CurrencyAmountValue" type="foo:CurrencyAmountType" substitutionGroup="foo:AmountOrPercentage"/>

<xs:element name="PercentageValue" type="foo:WholePercentType" substitutionGroup="foo:AmountOrPercentage"/>

NPE is thrown in CommonUtils line 98 with the annotation arg to the function being null. This is caused by XmlElementWrapperPlugin line 533 failing to get the target property annotation as the field actually has annotation javax.xml.bind.annotation.XmlElementRef and not as assumed javax.xml.bind.annotation.XmlElement so field xmlElementOriginalAnnotation will be null ... and then it unravels quickly.

I have added a unit test for this and will send a pull request for it shortly.

Element not selected as candidate

Given

<xs:element name="CategoryBoosts">
		<xs:annotation>
			<xs:documentation xml:lang="en">CategoryBoosts</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="hints:CategoryBoost" maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>

	<xs:element name="CategoryBoost">
		<xs:annotation>
			<xs:documentation xml:lang="en">See CategoryBoosts Element</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:attribute name="CatID" type="xs:string" use="required"/>
			<xs:attribute name="TreeID" type="xs:string" use="required"/>
			<xs:attribute name="BoostFactor" type="xs:float" use="optional" default="1.0"/>
			<xs:attributeGroup ref="common:LanguageSensitive"/>
		</xs:complexType>
	</xs:element>

and (in a different XSD, I'm using episodic compilation)

 <xs:element name="Rules">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="hints:CategoryBoosts"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

Why doesn't the plugin pick hints:CategoryBoosts as a candidate?

Issues with plugin - incompatible types

Hi,

I work on project using your plugin inside maven-jaxb2-plugin and facing some issue with incompatible types, not sure how to change XSD to fix this.

The whole project is available at:
http://ip-dev01.coreso.eu/gitlab/architecture/enterprise-integration/common-data-model

the pom.xml I am having issue with is under cdm-pojo module. The path to schemas is defined in the plugin configuration and points to cdm-schemas/.... directory(ies).

Thanks for hint and this plugin.

If you run mvn -X clean install you will hit the errors, but just for some small reference here is log snippet:

[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/CommonMessageHeaderType.java:[328,47] incompatible types: java.util.List<eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertyType> cannot be converted to eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertiesType
[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/CommonMessageHeaderType.java:[400,47] incompatible types: java.util.List<eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertyType> cannot be converted to eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertiesType
[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/CommonMessageHeaderType.java:[402,47] incompatible types: java.util.List<eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertyType> cannot be converted to eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertiesType
[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/CommonMessageHeaderType.java:[475,47] incompatible types: java.util.List<eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertyType> cannot be converted to eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertiesType
[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/CommonMessageHeaderType.java:[575,58] incompatible types: java.util.List<eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertyType> cannot be converted to eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertiesType
[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/CommonMessageHeaderType.java:[577,40] incompatible types: eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertiesType cannot be converted to java.util.List<eu.coreso.integration.integrationobjectlibrary.core.common.v1.PropertyType>
[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/MessageIdentificationType.java:[218,13] cannot find symbol
  symbol:   class BusinessObjectDocuments
  location: class eu.coreso.integration.integrationobjectlibrary.core.common.v1.MessageIdentificationType
[ERROR] /home/zangetsu/proj/coreso/common-data-model/cdm-pojo/target/generated-sources/xjc/eu/coreso/integration/integrationobjectlibrary/core/common/v1/MessageIdentificationType.java:[270,13] cannot find symbol
  symbol:   class BusinessObjectDocuments

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.