NullPointerException while unmarshalling with JAXB 1.0


XML & Web services: NullPointerException while unmarshalling with JAXB 1.0

  1. I'm assuming this has to do with namespaces but I'm not sure how to make JAXB handle it. The instance document I'm using does validate against the schema. We are using namespaces, but they are unqualified in the returned document. In the schema doc, there is xmlns='my.namespace', targetNamespace='my.namespace', elementFormDefault='qualified', and in the instance doc it is simply declared xmlns='my.namespace'. But there are no namespace prefixes for the elements. Is this the problem? Does JAXB not have issues with namespaces while it is generating the java object files from the Schema? They appeared to generate and compile just fine. Here's what I'm trying to do, very simple : Document response = service.getResponse(); JAXBContext jc = JAXBContext.newInstance( "my.package" ); Unmarshaller u = jc.createUnmarshaller(); RootClass root = (RootClass) u.unmarshal(response); and the error stack trace is : java.lang.NullPointerException at com.sun.xml.bind.unmarshaller.SAXUnmarshallerHandlerImpl.startElement( at com.sun.xml.bind.unmarshaller.DOMScanner.visit( at com.sun.xml.bind.unmarshaller.DOMScanner.parse( at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal( at Thanks FYI, Due to our environment, we're stuck using Java 1.3, which means JAXB 1.0 (I think)
  2. Hi, I am facing the same problem. W e are using JAXB1.o . and xsd schema for validation. unmarshalling when I try to get attribute it returns null. Do you know solution for it Thanx in advance