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

Property 'XXXX' is already defined. Use <jaxb:property> to resolve this conflict. #34

Open
martosoler opened this issue May 27, 2015 · 2 comments

Comments

@martosoler
Copy link

I'm trying to generate the Java classes from a zip file with a bunch of schemas files plus some binding files.
My gradle build file is as follows:

dependencies {
    jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41' //jaxws 2.2.6 uses jaxb 2.2.5, but can't dL 2.2.5 from maven the pom is off TODO
    jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7-b41'
    jaxb 'javax.xml.bind:jaxb-api:2.2.7'

    jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.6.5"
    jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-annotate:0.6.5"
}

jaxb {
    xsdDir = "/src/main/resources/schema"
    bindings = ["bindings.xjc","bindings2.xjc"]
    xjc {
        taskClassname      = "org.jvnet.jaxb2_commons.xjc.XJC2Task"
        generatePackage    = "com.soler.xsd"
        args               = ["-Xannotate"]
    }
}

When I execute gradle xjc, I'm getting the following error:

14:02:32.917 [ERROR] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:xjc] [ERROR] Property "Type" is already defined. Use <jaxb:property> to resolve this conflict.
14:02:32.921 [ERROR] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:xjc]   line 494 of file:/C:/dev/XXX/src/main/resources/schema/external/YYY/ZZZ.xsd
14:02:32.922 [ERROR] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:xjc]
14:02:32.923 [ERROR] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:xjc] [ERROR] The following location is relevant to the above error
14:02:32.923 [ERROR] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:xjc]   line 540 of file:/C:/dev/XXX/src/main/resources/schema/external/YYY/ZZZ.xsd
14:02:32.924 [ERROR] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:xjc]
14:02:32.941 [ERROR] [org.gradle.BuildExceptionReporter]
14:02:32.942 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:02:32.944 [ERROR] [org.gradle.BuildExceptionReporter]
14:02:32.945 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
14:02:32.945 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':ext/stix:xjc'.
14:02:32.946 [ERROR] [org.gradle.BuildExceptionReporter] > unable to parse the schema. Error messages should have been provided
14:02:32.948 [ERROR] [org.gradle.BuildExceptionReporter]
14:02:32.949 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
14:02:32.950 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.

Many places recommend the following link Dealing with errors but I'm not sure how that applies to this plugin.

Thanks

@tkent
Copy link

tkent commented Jun 17, 2015

@martosoler you may have already realized this, given the age of this post, but the cause of your issue isn't this plugin. It's a legit problem that is causing xjc to be unable to create a class for an element.

The most likely culprit, in my experience, is that a child element and attribute have the same name (if a case-insensitive match is done). These happen often and are short work to square up using and xjb file to ensure distinct names. For example

...
  <jaxb:bindings schemaLocation="file:/C:/dev/XXX/src/main/resources/schema/external/YYY/ZZZ.xsd">
    <jaxb:schemaBindings>
      <jaxb:package name="com.soler.xsd"/>
    </jaxb:schemaBindings>
    <!-- Used to avoid the duplicate element/attribute name conflict -->
    <jaxb:bindings node="//xsd:attribute[@name='dataSource']">
      <jaxb:property name="typeAttr"/>
    </jaxb:bindings>
  </jaxb:bindings>
...

@wdschei
Copy link

wdschei commented Sep 9, 2016

@martosoler & @tkent

The OpenRepose.org updated version of this plugin is now available in the Gradle Plugins repository and is compatible with JSE7.

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