users@jaxb.java.net

Re: Code generation error

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_sun.com>
Date: Tue, 24 Jun 2003 14:46:53 -0400

Aaron Stromas wrote:

> Ryan Shoemaker - JavaSoft East said:
>
>>Aaron Stromas wrote:
>>
>>
>>>Greetings,
>>>
>>>I'm new to JAXP, and I've run into an error trying to generate code
>>>from my schema. The schema is correct, validated by Xerces and XmlSpy,
>>>but running xjc.sh fails:
>>>
>>>$ xjc.sh -xmlschema sps.xsd -b binding.xjb -d .
>>>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.GrammarLoader.buildDOMForest(GrammarLoader.java:315)
>>> at
>>> com.sun.tools.xjc.GrammarLoader.loadXMLSchema(GrammarLoader.java:346)>> at
>>> com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:125)
>>> at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:71)
>>> at com.sun.tools.xjc.Driver.run(Driver.java:192)
>>> at com.sun.tools.xjc.Driver._main(Driver.java:82)
>>> at com.sun.tools.xjc.Driver.access$000(Driver.java:48)
>>> at com.sun.tools.xjc.Driver$1.run(Driver.java:62)
>>>
>>
>>Aaron,
>>
>>This normally indicates a problem with the classpath, but since you're
>>running xjc.sh it should be taking care of all the settings for you.
>>Can you boil your schema down to a simple test case that reproduces the
>>problem and send it to the list?
>>
>
>
> Ryan,
>
> Admittedly my schema is quite large, but quite unexpectedly one of the toy
> schemas I have around fails in the same way:
>
> [snip]
>
> Does it fail for you?
>

Nope, it runs fine:

> LORAX [43] =>d:/jwsdp-1.2/jaxb/bin/xjc foo.xsd
> parsing a schema...
> compiling a schema...
> localhost\test_1\impl\ExtractUploadRecordImpl.java
> localhost\test_1\impl\ExtractUploadRecordTypeImpl.java
> localhost\test_1\impl\JAXBVersion.java
> localhost\test_1\impl\MessageImpl.java
> localhost\test_1\impl\MessageTypeImpl.java
> localhost\test_1\impl\PayloadImpl.java
> localhost\test_1\impl\PayloadTypeImpl.java
> localhost\test_1\impl\SPSMessageImpl.java
> localhost\test_1\impl\SPSMessageTypeImpl.java
> localhost\test_1\impl\runtime\PrefixCallback.java
> localhost\test_1\impl\runtime\DefaultJAXBContextImpl.java
> localhost\test_1\impl\runtime\MarshallerImpl.java
> localhost\test_1\impl\runtime\NamespaceContextImpl.java
> localhost\test_1\impl\runtime\SAXUnmarshallerHandlerImpl.java
> localhost\test_1\impl\runtime\GrammarInfo.java
> localhost\test_1\impl\runtime\ErrorHandlerAdaptor.java
> localhost\test_1\impl\runtime\ValidationContext.java
> localhost\test_1\impl\runtime\XMLSerializable.java
> localhost\test_1\impl\runtime\ContentHandlerAdaptor.java
> localhost\test_1\impl\runtime\GrammarInfoFacade.java
> localhost\test_1\impl\runtime\XMLSerializer.java
> localhost\test_1\impl\runtime\AbstractUnmarshallingEventHandlerImpl.java
> localhost\test_1\impl\runtime\SAXMarshaller.java
> localhost\test_1\impl\runtime\UnmarshallerImpl.java
> localhost\test_1\impl\runtime\SAXUnmarshallerHandler.java
> localhost\test_1\impl\runtime\UnmarshallableObject.java
> localhost\test_1\impl\runtime\AbstractGrammarInfoImpl.java
> localhost\test_1\impl\runtime\UnmarshallingContext.java
> localhost\test_1\impl\runtime\UnmarshallingEventHandlerAdaptor.java
> localhost\test_1\impl\runtime\NamespaceContext2.java
> localhost\test_1\impl\runtime\UnmarshallingEventHandler.java
> localhost\test_1\impl\runtime\ValidatingUnmarshaller.java
> localhost\test_1\impl\runtime\Util.java
> localhost\test_1\impl\runtime\Discarder.java
> localhost\test_1\impl\runtime\ValidatableObject.java
> localhost\test_1\impl\runtime\MSVValidator.java
> localhost\test_1\impl\runtime\ValidatorImpl.java
> org\w3\_2001\xmlschema\impl\AnyTypeImpl.java
> org\w3\_2001\xmlschema\impl\JAXBVersion.java
> org\w3\_2001\xmlschema\AnyType.java
> org\w3\_2001\xmlschema\ObjectFactory.java
> org\w3\_2001\xmlschema\bgm.ser
> org\w3\_2001\xmlschema\jaxb.properties
> localhost\test_1\ExtractUploadRecord.java
> localhost\test_1\ExtractUploadRecordType.java
> localhost\test_1\Message.java
> localhost\test_1\MessageType.java
> localhost\test_1\ObjectFactory.java
> localhost\test_1\Payload.java
> localhost\test_1\PayloadType.java
> localhost\test_1\SPSMessage.java
> localhost\test_1\SPSMessageType.java
> localhost\test_1\bgm.ser
> localhost\test_1\jaxb.properties
> LORAX [44] =>echo $JAXB_HOME
> d:/jwsdp-1.2/jaxb
> LORAX [45] =>echo $CLASSPATH
>
> LORAX [46] =>echo $JAVA_HOME
> d:/jdk1.4.1_03



You can either try unsetting your classpath before using the xjc.sh script
or you can try executing the jar manually:

> LORAX [50] =>java -jar d:/jwsdp-1.2/jaxb/lib/jaxb-xjc.jar foo.xsd
> parsing a schema...
> compiling a schema...
> localhost\test_1\impl\ExtractUploadRecordImpl.java
> localhost\test_1\impl\ExtractUploadRecordTypeImpl.java
> [etc]

--Ryan


> -a
>
> --
> Aaron Stromas | "Tik-tik-tik!!!... ja, Pantani is weg..."
> mailto:ams_at_izoard.com | BRTN commentator
> +1 (301) 493 4933 | L'Alpe d'Huez
> http://www.izoard.com | 1995 Tour de France
>