You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Chris Kirk <mr...@yahoo.co.uk> on 2004/01/31 13:20:46 UTC

NullPointerEexception with tags of simpleType (and proposed patch)

In the latest code checked into CVS I noticed the following problem, a NullPointerException when an xsd file contains something similar to the following:
 
 <xs:element name="documentation">
  <xs:annotation>
   <xs:documentation>Add more documentation over and above that supplied by the description.</xs:documentation>
  </xs:annotation>
  <xs:simpleType>
   <xs:restriction base="xs:string">
    <xs:whiteSpace value="preserve"/>
   </xs:restriction>
  </xs:simpleType>
 </xs:element>

The reason appears to be that generateJaxbProperties creates a list of ObjectSG's, it then goes on assuming that all ObjectSG's are complex.. and as such getClassContext will always return a non-null value. Alas this is not true for elements defined as simpleTypes.
 
 
Patch to JAXBSchemaSG.generateJaxbProperties().
 
The following patch appears to work for me, hope it is of use. 
 
 
RCS file: /home/cvspublic/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java,v
retrieving revision 1.6
diff -r1.6 JAXBSchemaSG.java
394a395
> 
437a439
> 
442c444,448
<       contextList.add(elements[i]);
---
>       if ( elements[i].getClassContext() != null ) {
>         // assumption here is that the object here is a simple type, and
>         // we are only interested in complex ones
>         contextList.add(elements[i]);
>       }
 

 

- Chris.

 

PS. I also noticed that hsqldb-1.7.1.jar is in the .cvsignore for the prerequisites directory.. this makes the build break for new checkouts, it would be helpful for newbies if this was either checked in like the other prerequisites or a readme in the root directory tells people that they need to download hsqldb before running the build.


---------------------------------
BT Yahoo! Broadband - Free modem offer, sign up online today and save £80