Sunday, August 1, 2010

com.bea.xml.XmlException: error: The document is not a WLJMSMessage@http://www.bea.com/WLS/JMS/Message

When importing a message in a Queue in WebLogic, make sure the XML complies to a specific schema:

element WLJMSMessage
namespace http://www.bea.com/WLS/JMS/Message

An empty message looks like:


<?xml version="1.0" encoding="UTF-8"?>
<mes:WLJMSMessage xmlns:mes="http://www.bea.com/WLS/JMS/Message">
<mes:Header/>
</mes:WLJMSMessage>


If you process this message with a MDB,




public void onMessage(Message message) {
TextMessage tm = (TextMessage)message;
try {
System.out.println("!!!message " + tm.getText());
} catch (JMSException e) {
e.printStackTrace();
}

}



you will get this:

MessageDrivenBean threw an Exception in onMessage(). The exception was: java.lang.ClassCastException: weblogic.jms.common.HdrMessageImpl



Since delivery fails, I also get this:

The Message-Driven EJB: MQGeoFeedMDB is throwing exception when processing the messages. Delivery failed after 139 attempts. The EJB container will suspend the message delivery for 60 seconds before retry.




A complete sample WL Message has this format:



<?xml version="1.0" encoding="UTF-8"?>
<JMSMessageExport>
<mes:WLJMSMessage xmlns:mes="http://www.bea.com/WLS/JMS/Message">
<mes:Header>
<mes:JMSMessageID>ID:&lt;654066.1280681376262.0></mes:JMSMessageID>
<mes:JMSDeliveryMode>PERSISTENT</mes:JMSDeliveryMode>
<mes:JMSExpiration>0</mes:JMSExpiration>
<mes:JMSPriority>4</mes:JMSPriority>
<mes:JMSRedelivered>false</mes:JMSRedelivered>
<mes:JMSTimestamp>1280681376262</mes:JMSTimestamp>
<mes:Properties>
<mes:property name="JMSXDeliveryCount">
<mes:Int>0</mes:Int>
</mes:property>
</mes:Properties>
</mes:Header>
<mes:Body>
<mes:Text>your message here</mes:Text>
</mes:Body>
</mes:WLJMSMessage>
</JMSMessageExport>



No comments: