Results 1 to 3 of 3

Thread: SimpleMessageConverter throwing MessageFormatException

  1. #1
    Join Date
    Nov 2005
    Location
    Charlotte,NC
    Posts
    57

    Default 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. #2
    Join Date
    Mar 2005
    Location
    The Netherlands
    Posts
    121

    Default

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

  3. #3
    Join Date
    Nov 2005
    Location
    Charlotte,NC
    Posts
    57

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •