views:

83

answers:

1

Hi,

I am using JMS Messaging in my java program. My messages are coming from IBM Main Frame and the messages are xml files.

Mainframe pushes messages that is xml files to the queue

But when the java program reads the messages from the queue an additional character "?" gets added in front of the xml file. For example a file like this:

<?xml version="1.0" encoding="UTF-8"?>

becomes

?<?xml version="1.0" encoding="UTF-8"?>

when I read the message from the queue.

And when I try to parse this I catch the following exception

SAX Exception org.xml.sax.SAXParseException: Content is not allowed in trailing section. Content is not allowed in trailing section

What could be the reason for this additional character getting added ?

A: 

the first questionmark is byte-order mark.

are you given string content to parser ?

Santhosh Kumar T
Yes we are giving string content to the parser
Anand
You must use correct encoding to construct string.best option is give raw byte array/stream to parser, so that parser takes care of encoding.
Santhosh Kumar T
Ok will try that
Anand