eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
205 stars 111 forks source link

"trying to create the same field twice" error doesn't report line number #512

Open Tomas-Kraus opened 16 years ago

Tomas-Kraus commented 16 years ago

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. (SingleField.java:89) at com.sun.tools.xjc.generator.bean.field.SingleField. (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.(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 .)

Environment

Operating System: All Platform: All URL: http://www.hl7.org/v3ballot/html/infrastructure/cda/cda.htm#CDA_Schema

Affected Versions

[2.1.7]

Tomas-Kraus commented 6 years ago
Tomas-Kraus commented 16 years ago

@glassfishrobot Commented Reported by nradov

Tomas-Kraus commented 13 years ago

@glassfishrobot Commented snajper said: exception shall be caught and rethrown with current location

Tomas-Kraus commented 13 years ago

@glassfishrobot Commented scarcher2 said: I'm having the same problem. Trying to generate classes from the CDA Schema files.

Tomas-Kraus commented 16 years ago

@glassfishrobot Commented Issue-Links: blocks JAXB-508

Tomas-Kraus commented 16 years ago

@glassfishrobot Commented Was assigned to snajper

Tomas-Kraus commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-512

Tomas-Kraus commented 6 years ago

@stdunbar Commented Still a problem in 2.2.8-b130911.1802 10 years later.