3

When I use jxb:class with annox:annotate, I get this exception:

com.sun.istack.SAXParseException2; systemId: file:/usr/workspace/project/package/file.xjb; lineNumber: 16; columnNumber: 35; the compiler failed to honor this customization annox: annotate. He was attached to an incorrect location or is inconsistent with other binds.
    at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:86)
    at com.sun.tools.xjc.model.Model.generateCode(Model.java:310)
    at com.sun.tools.xjc.Driver.run(Driver.java:363)
    at org.codehaus.mojo.jaxb2.AbstractXjcMojo.execute(AbstractXjcMojo.java:316)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    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:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)

I used this configuration:

<jxb:bindings node="xs:complexType[@name='MyType']//xs:element[@name='property']">
    <jxb:class ref="org.project.model.MyType" />
</jxb:bindings>
hoijui
  • 3,615
  • 2
  • 33
  • 41
Ismael G.
  • 378
  • 1
  • 2
  • 10

1 Answers1

1

EDIT: I might have been wrong about my interpretation. I'll still leave the answer until we've got it cleared.


Author of and here.

It is quite obvious that it won't work.

This:

<jxb:class ref="org.project.model.MyType" />

Instructs JAXB to use a presumably existing class org.project.model.MyType instead of generating a new on. So there's no class generated, so has nothing to add annotations to.

I hope it is clear, why you can't add annotations to the already existing classes. :) That would be too much to ask. You can only add annotations to the generated classes.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • I want to add annotations at the field, not at the class. That's my problem. `code ` – Ismael G. Aug 28 '15 at 12:26
  • @IsmaelG. Does `jaxb:class` works without `annox:annotate`? Here? And try to write two separate bindings for `jaxb:class` and for `annox:annotate`. – lexicore Aug 28 '15 at 12:31
  • Yes, `jaxb:class` works without `annox:annotate`. But when I write two separate bindings for each one, I get the same exception as I mentioned before. – Ismael G. Aug 28 '15 at 13:48
  • @IsmaelG. Ok, this might be a bug. Please file an issue here https://github.com/highsource/jaxb2-annotate-plugin/issues send me PR a minimal reproducing project here: https://github.com/highsource/jaxb2-annotate-plugin/tree/master/tests – lexicore Aug 28 '15 at 13:50
  • I have an example of the problem here: https://github.com/mundodojava/jaxb2-maven-plugin – Ismael G. Aug 31 '15 at 13:17
  • @IsmaelG. I'll take a look but give me time. – lexicore Aug 31 '15 at 17:59