• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ParserConfigurationException:

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using MessageDrivenBean and WebsphereMq as JMS provider.I wil get the messages as string which are in xml format.using TransformerFactory and Transformer i wil convert the string as Xml,after that i wil parse the nodes of these xml and insert the details in databse.For parsing i am using documentbuilder object.

After processing few messages it is throwing ParserConfigurationException and it is happening rarely.Can anyone suggest me what will be the reason and how can i wil overcome this exception.

The below is the code snippet throwing the exception.

DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
TransformerFactory transformerFactory = TransformerFactorynewInstance();

Transformer transformer = transformerFactory.newTransformer();
StringReader stingReader = new StringReader(message);
StreamSource src = new StreamSource(stingReader);

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

StreamResult result = new StreamResult(outputStream);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(src, result);

ByteArrayInputStream inputStream = new ByteArrayInputStream(
outputStream.toByteArray());

InputSource inputSource = new InputSource(inputStream);

DocumentBuilder builder = builderFactory.newDocumentBuilder(); ----exception is throwing from here
Document document = builder.parse(inputSource);

 
reply
    Bookmark Topic Watch Topic
  • New Topic