jaxb-v2 icon indicating copy to clipboard operation
jaxb-v2 copied to clipboard

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

Open glassfishrobot opened this issue 16 years ago • 7 comments

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]

glassfishrobot avatar Jun 06 '08 15:06 glassfishrobot

Reported by nradov

glassfishrobot avatar Jun 06 '08 15:06 glassfishrobot

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

glassfishrobot avatar Apr 15 '11 06:04 glassfishrobot

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

glassfishrobot avatar Aug 30 '11 03:08 glassfishrobot

Issue-Links: blocks JAXB-508

glassfishrobot avatar Jun 06 '08 15:06 glassfishrobot

Was assigned to snajper

glassfishrobot avatar Jun 06 '08 15:06 glassfishrobot

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

glassfishrobot avatar Apr 24 '17 12:04 glassfishrobot

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

stdunbar avatar Sep 14 '18 16:09 stdunbar