javax.xml.bind.UnmarshalException - with linked exception:

Sara picture Sara · Aug 6, 2014 · Viewed 15.3k times · Source

I have got receive an xml inputstream with a URLConnection. However when i try to unmarshall the inputstream. It throw an exception. javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.stream.XMLStreamException: ParseError at [row,col]:[53088,40] Message: The reference to entity "T" must end with the ';' delimiter.]

CODE:

try {
    URL url = new URL(hostURL);  
    URLConnection urlConnection = url.openConnection();  
    urlConnection.setRequestProperty("Accept", "application/xml");
    urlConnection.setRequestProperty("Authorization", "Basic " + authDetails);

    InputStream inputStream = urlConnection.getInputStream();

    XMLInputFactory xif = XMLInputFactory.newInstance();
    xif.setProperty("javax.xml.stream.isCoalescing", true); 
    XMLStreamReader xsr = xif.createXMLStreamReader(inputStream);

     // Advance to the "Packages" element.
     while(xsr.hasNext()) {
         if(xsr.isStartElement() && "packages".equals(xsr.getLocalName())) {
             break;
         }
         xsr.next();
      }

     JAXBContext jaxbContext = JAXBContext.newInstance(Packages.class);
     Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
     packages = (Packages) jaxbUnmarshaller.unmarshal(xsr);
    }catch (JAXBException e) {
     e.printStackTrace();
    }catch (MalformedURLException e) {
     e.printStackTrace();
    }catch (IOException e) {
     e.printStackTrace();
    }catch(Exception e){
     e.printStackTrace();
     }finally{

    }

PS: [row,col]:[53088,40] = newproductsite for T&T evol

you can find Stack traces in link http://pastebin.com/LuhbnMQq

Guys am new to this thing and stuck with it, any help would be appreciated

BR Sara

Answer

laune picture laune · Aug 6, 2014

Your XML file isn't well-formed.

newproductsite for T&T evol

You cannot have a '&' in the XML file, it must be represented as

&

How was the XML produced? The error is there...