I found something that is pretty minimal and reproducible:
<?xml version="1.0"?>
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:jxb="
http://java.sun.com/xml/ns/jaxb"
jxb:version="1.0">
<xs:annotation>
<xs:appinfo>
<jxb:globalBindings
collectionType="indexed"
choiceContentProperty="true"
bindingStyle="modelGroupBinding"/>
<jxb:schemaBindings>
<jxb:package name="com.test"/>
</jxb:schemaBindings>
</xs:appinfo>
</xs:annotation>
<xs:element name="Foo">
<xs:complexType>
<xs:sequence>
<xs:group ref="Bar"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="Bar">
<xs:choice>
<xs:element name="A" type="xs:string" maxOccurs="unbounded"/>
<xs:element name="B" type="xs:string"/>
</xs:choice>
</xs:group>
</xs:schema>
I really want to put JAXB into production but has been banging my heads.
A big sigh and I'm going to bed.
Han Ming
On Tuesday, March 18, 2003, at 07:12 PM, Han Ming Ong wrote:
> Hi JAXB-gurus,
>
> I searched the archive. Not there, hence I'm reporting here.
>
> parsing a schema...
> compiling a schema...
> java.lang.reflect.InvocationTargetException:
> java.lang.IllegalStateException: Variable already initialized
> at com.sun.codemodel.JVar.init(JVar.java:71)
> at
> com.sun.tools.xjc.generator.field.AbstractListFieldRenderer.getOnSetEve
> n
> tHandler(AbstractListFieldRenderer.java:106)
> at
> com.sun.tools.xjc.generator.SkeletonGenerator.generateChoiceContentFiel
> d
> (SkeletonGenerator.java:238)
> at
> com.sun.tools.xjc.generator.SkeletonGenerator.<init>(SkeletonGenerator.
> j
> ava:130)
> at
> com.sun.tools.xjc.generator.SkeletonGenerator.generate(SkeletonGenerato
> r
> .java:92)
> at com.sun.tools.xjc.Driver.generateCode(Driver.java:728)
> at com.sun.tools.xjc.Driver.run(Driver.java:423)
> at com.sun.tools.xjc.Driver._main(Driver.java:113)
> at com.sun.tools.xjc.Driver.access$000(Driver.java:77)
> at com.sun.tools.xjc.Driver$1.run(Driver.java:93)
>
> So what causes this?
>
> I have part of the schema segment:
>
> <xs:annotation>
> <xs:appinfo>
> <jxb:globalBindings
> collectionType="indexed"
> bindingStyle="modelGroupBinding"/>
>
> <jxb:schemaBindings>
> <jxb:package name="com.test"/>
> </jxb:schemaBindings>
> </xs:appinfo>
> </xs:annotation>
>
> <xs:element name="Foo">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="comment" type="xs:string" minOccurs="0"
> maxOccurs="unbounded"/>
> <xs:group ref="Bar" maxOccurs="unbounded" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> <xs:group name="Bar">
> <xs:choice>
> <xs:element name="A" type="xs:string"/>
> <xs:element name="B" type="xs:string"/>
> <xs:element name="C" type="xs:string"/>
> </xs:choice>
> </xs:group>
>
> If I have a simple schema file that just includes the segment above, it
> will *not* have the exception.
>
> The exception occurs when the segment is part of a much larger schema
> file, which unfortunately I'm not in the liberty to reveal here :-(.
> Maybe you can insert it into any big schema file that you have (and
> turn on modelGroupBinding style) and perhaps you will see the
> exception.
>
> Back to more immediate goal: how should I work around this? split into
> multiple smaller schemas?
>
> thanks much.
>
> Mac OS X, 10.2.4 JDK 1.3.1