org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jsonschema2pojo:jsonschema2pojo-maven-plugin:0.4.24:generate (generate-api) on project xyz-spec: Execution generate-api of goal org.jsonschema2pojo:jsonschema2pojo-maven-plugin:0.4.24:generate failed: trying to create the same field twice: additionalProperties

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • GitHub comment 608#239608389
    via GitHub by ctrimble
    ,
  • Trace: Exception in thread "main" java.lang.IllegalArgumentException: trying to create the same field twice: ts1EnbDirectInfoTransferTrir at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:421) at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:392) at com.sun.tools.xjc.generator.bean.field.AbstractFieldWithVar.createField(AbstractFieldWithVar.java:77) at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField.java:94) at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField.java:81) at sun.reflect.GeneratedConstructorAccessor8.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.sun.tools.xjc.generator.bean.field.GenericFieldRenderer.generate(GenericFieldRenderer.java:69) at com.sun.tools.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFieldRenderer.java:84) at com.sun.tools.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.java:764) at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.java:545) at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:248) at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:166) at com.sun.tools.xjc.model.Model.generateCode(Model.java:290) at com.sun.tools.xjc.Driver.run(Driver.java:348) at com.sun.tools.xjc.Driver.run(Driver.java:196) at com.sun.tools.xjc.Driver._main(Driver.java:121) at com.sun.tools.xjc.Driver.access$000(Driver.java:79) at com.sun.tools.xjc.Driver$1.run(Driver.java:101) In XML I have two fields with the same name, but the are in different cases, which is legal: <!-- - Name: ts1EnbDirectInfoTransferTrir - Defined in: lte.NaccTimersConf - Units: ms - Min/Max: 1 to 10000 - Default: 3000 - Access: Read-Write --> <xsd:element name="ts1EnbDirectInfoTransferTrir" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:int"> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="10000"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <!-- - Name: tS1EnbDirectInfoTransferTrir - Defined in: lte.NaccTimersConf - Units: ms - Min/Max: 1 to 10000 - Default: 3000 - Access: Read-Write --> <xsd:element name="tS1EnbDirectInfoTransferTrir" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:int"> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="10000"/> </xsd:restriction> </xsd:simpleType> </xsd:element>
    via by wargoth,
  • Try downloading all of the XML Schema files from the web page linked above and then run xjc on CDA.xsd to generate the equivalent Java code. It will fail with this error. Exception in thread "main" java.lang.IllegalArgumentException: trying to create the same field twice: id at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:419) at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:390) at com.sun.tools.xjc.generator.bean.field.AbstractFieldWithVar.createField (AbstractFieldWithVar.java:71) at com.sun.tools.xjc.generator.bean.field.SingleField.<init> (SingleField.java:89) at com.sun.tools.xjc.generator.bean.field.SingleField.<init> (SingleField.java:76) at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.sun.tools.xjc.generator.bean.field.GenericFieldRenderer.generate (GenericFieldRenderer.java:64) at com.sun.tools.xjc.generator.bean.field.DefaultFieldRenderer.generate (DefaultFieldRenderer.java:75) at com.sun.tools.xjc.generator.bean.BeanGenerator.generateFieldDecl (BeanGenerator.java:744) at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassBody (BeanGenerator.java:532) at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:234) at com.sun.tools.xjc.generator.bean.BeanGenerator.generate (BeanGenerator.java:174) at com.sun.tools.xjc.model.Model.generateCode(Model.java:286) at com.sun.tools.xjc.Driver.run(Driver.java:343) at com.sun.tools.xjc.Driver.run(Driver.java:191) at com.sun.tools.xjc.Driver._main(Driver.java:116) at com.sun.tools.xjc.Driver.access$000(Driver.java:74) at com.sun.tools.xjc.Driver$1.run(Driver.java:96) The error message is correct, but not helpful. In all other cases when there is an error in an XML Schema file, xjc reports the exact line number where the problem exists. It should also report the line number for a duplicate field name. That would have made it much easier to identify the underlying problem. (For a full description see this discussion thread: http://forums.java.net/jive/message.jspa?messageID=278722 .)
    via by nradov,
    • org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jsonschema2pojo:jsonschema2pojo-maven-plugin:0.4.24:generate (generate-api) on project xyz-spec: Execution generate-api of goal org.jsonschema2pojo:jsonschema2pojo-maven-plugin:0.4.24:generate failed: trying to create the same field twice: additionalProperties at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 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:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 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:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate-api of goal org.jsonschema2pojo:jsonschema2pojo-maven-plugin:0.4.24:generate failed: trying to create the same field twice: additionalProperties at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: java.lang.IllegalArgumentException: trying to create the same field twice: additionalProperties at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:425) at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:396) at org.jsonschema2pojo.rules.AdditionalPropertiesRule.addAdditionalPropertiesField(AdditionalPropertiesRule.java:128) at org.jsonschema2pojo.rules.AdditionalPropertiesRule.apply(AdditionalPropertiesRule.java:108) at org.jsonschema2pojo.rules.AdditionalPropertiesRule.apply(AdditionalPropertiesRule.java:43) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:135) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:66) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30) at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:75) at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43) at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:64) at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:32) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:125) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:66) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30) at org.jsonschema2pojo.rules.ArrayRule.apply(ArrayRule.java:81) at org.jsonschema2pojo.rules.ArrayRule.apply(ArrayRule.java:37) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:113) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30) at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:75) at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43) at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:64) at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:32) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:125) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:66) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30) at org.jsonschema2pojo.rules.ArrayRule.apply(ArrayRule.java:81) at org.jsonschema2pojo.rules.ArrayRule.apply(ArrayRule.java:37) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:113) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30) at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:75) at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:43) at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:64) at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:32) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:125) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:70) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:90) at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:40) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:73) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:66) at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:30) at org.jsonschema2pojo.SchemaMapper.generate(SchemaMapper.java:92) at org.jsonschema2pojo.Jsonschema2Pojo.generate(Jsonschema2Pojo.java:75) at org.jsonschema2pojo.maven.Jsonschema2PojoMojo.execute(Jsonschema2PojoMojo.java:594) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 20 more
    No Bugmate found.