Hi all,
I'm trying to get JAXB to generate the
java classes by using xjc.sh on test.xsd (shown below). Apparently, JAXB does not like it when i try to use extension on a complexType/simpleContent/Restriction? Is there something i'm doing wrong or does xjc.sh not support what i'm trying to do? Would appreciate any help/hints. Thanks!
I am using jwsdp-1.3 and j2sdk1.4.1_02.
I've tried the following command line invocations:
xjc.sh -p <package name> -d <working dir> test.xsd
xjc.sh -p <package name> test.xsd
xjc.sh test.xsd
----- test.xsd -----
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http/www/test"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:se="http/www/test" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Root" type="se:CSEonCSR">
<xs:annotation>
<xs
ocumentation>Root element</xs
ocumentation>
</xs:annotation>
</xs:element>
<!-- this guy is the culprit..causes error with either simpleContent or complexContent -->
<xs:complexType name="CSEonCSR">
<xs:simpleContent>
<xs:extension base="se:CSRonCSE"/>
</xs:simpleContent>
</xs:complexType>
<!-- this is the guy that CSEonCSR cannot use extension on -->
<xs:complexType name="CSRonCSE">
<xs:simpleContent>
<xs:restriction base="se:CSE">
<xs:minLength value="1"/>
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="CSE">
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
----- error -----
parsing a schema...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.launcher.ChildMain.run(ChildMain.java:269)
Caused by: java.lang.NullPointerException
at com.sun.tools.xjc.reader.xmlschema.ct.ExtendedComplexTypeBuilder.getNameClass(ExtendedComplexTypeBuilder.java:226)
at com.sun.tools.xjc.reader.xmlschema.ct.ExtendedComplexTypeBuilder.checkIfExtensionSafe(ExtendedComplexTypeBuilder.java:181)
at com.sun.tools.xjc.reader.xmlschema.ct.ExtendedComplexTypeBuilder.build(ExtendedComplexTypeBuilder.java:75)
at com.sun.tools.xjc.reader.xmlschema.ct.ComplexTypeFieldBuilder.build(ComplexTypeFieldBuilder.java:56)
at com.sun.tools.xjc.reader.xmlschema.FieldBuilder.complexType(FieldBuilder.java:228)
at com.sun.xml.xsom.impl.ComplexTypeImpl.apply(ComplexTypeImpl.java:194)
at com.sun.tools.xjc.reader.xmlschema.FieldBuilder.build(FieldBuilder.java:76)
at com.sun.tools.xjc.reader.xmlschema.cs.ClassSelector.build(ClassSelector.java:340)
at com.sun.tools.xjc.reader.xmlschema.cs.ClassSelector.access$000(ClassSelector.java:54)
at com.sun.tools.xjc.reader.xmlschema.cs.ClassSelector$Binding.build(ClassSelector.java:107)
at com.sun.tools.xjc.reader.xmlschema.cs.ClassSelector.executeTasks(ClassSelector.java:240)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:118)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:80)
at com.sun.tools.xjc.GrammarLoader.annotateXMLSchema(GrammarLoader.java:424)
at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:130)
at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:79)
at com.sun.tools.xjc.Driver.run(Driver.java:177)
at com.sun.tools.xjc.Driver._main(Driver.java:80)
at com.sun.tools.xjc.Driver.access$000(Driver.java:46)
at com.sun.tools.xjc.Driver$1.run(Driver.java:60)