title: JAXB : unmarshalexception - with linked exception: [java.io.IOException: Stream closed]
body: <p>I am trying to parse my xml using SAX ,I want to use JaxB to build my map my element name and its value.I also want to override startElement and endElemnt but I have reached here until so far and I am getting unmarshal exception.Any help is appreciated!.</p>
  
  <p>JAXBContext jaxbContext = JAXBContext.newInstance(my.class);  </p>
  
  <pre><code>      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 I unmarahall to specific class object still i get same exception.
  
      } catch (JAXBException e) {  
       // some exception occured  
         e.printStackTrace();  
      }
  </code></pre>