Announcement Announcement Module
Collapse
No announcement yet.
SimpleMessageConverter throwing MessageFormatException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleMessageConverter throwing MessageFormatException

    I am using a MessageConverter for the first time, and trying to use a SimpleMessageConverter to convert the results of an HttpServletRequest request.getParameterMap() to a MessageMap.
    Code:
        public void sendMessage(final Object msg)
        {
        if (LogManager.isDebug())
            LogManager.debug("Publishing msg: " + msg);
        jmsTemplate.convertAndSend(msg);
        }
    (where msg is a Map object)

    The call to message.setObject((String) entry.getKey(), entry.getValue());
    in SimpleMessageConverter is resulting in a MessageFormatException, and I don't understand why?

    The value it is trying to convert is "4"

    Code:
    javax.jms.MessageFormatException: CWSIA0188E: An incorrect object of type [Ljava.lang.String; was provided.
        at com.ibm.ws.sib.api.jms.impl.JmsMapMessageImpl.setObject(JmsMapMessageImpl.java:1066)
        at org.springframework.jms.support.converter.SimpleMessageConverter.createMessageForMap(SimpleMessageConverter.java)
        at org.springframework.jms.support.converter.SimpleMessageConverter.toMessage(SimpleMessageConverter.java:80)
        at org.springframework.jms.core.JmsTemplate$5.createMessage(JmsTemplate.java:569)
        at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:509)
    Can anyone suggest what might be wrong? I checked the code for MessageMap, and it indicates it should be able to handle a String value.

  • #2
    The value seems to be a String-array, not a String: that's what "type [Ljava.lang.String;" means.

    Comment


    • #3
      Thanx for catching what I missed. For the Javadoc for the ServletRequest interface:

      an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.

      Ed

      Comment

      Working...
      X