xml - JAXB : unmarshalexception - with linked exception: [java.io.IOException: Stream closed] -


i trying parse xml using sax ,i want use jaxb build map element name , value.i want override startelement , endelemnt have reached here until far , getting unmarshal exception.any appreciated!.

jaxbcontext jaxbcontext = jaxbcontext.newinstance(my.class);

      unmarshaller jaxbunmarshaller = jaxbcontext.createunmarshaller();          unmarshallerhandler unmarshallerhandler = jaxbunmarshaller.getunmarshallerhandler();       saxparserfactory spf = saxparserfactory.newinstance();      saxparser sp = spf.newsaxparser();      xmlreader xr = sp.getxmlreader();      xr.setcontenthandler(unmarshallerhandler);        inputstream inputstream =   this.getclass().getresourceasstream("my.xml");      inputsource inputsource = new inputsource(inputstream);       xr.parse(inputsource);          jaxbelement  element  = (jaxbelement) jaxbunmarshaller.unmarshal(inputsource);          //or if unmarahall specific class object still same exception.      } catch (jaxbexception e) {        // exception occured          e.printstacktrace();       } 

you can't unmarshal inputsource after have used sax parse on it. object call getresult on unmarshallerhandler.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -