NullPointerException while unmarshalling with JAXB 1.0

Discussions

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(SAXUnmarshallerHandlerImpl.java:87) at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:109) at com.sun.xml.bind.unmarshaller.DOMScanner.parse(DOMScanner.java:64) at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:149) at lmig.am.claims.covver.services.JAXBTester.main(JAXBTester.java:28) 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