Saturday, 8 May 2010

Spring error message - "can't parse argument number"

PROBLEM:
The story:
I want to display an error message that contains two dates which are derived from the exception returned by a remote web service that I'm calling from the webapp.

I'm almost there, since this error seems to relate to the display of the message, and the log also shows lines where it is going wrong in the JSP (the one with "form:errors")

2010-05-08 15:28:21,237 DEBUG
[org.springframework.context.support.ResourceBundleMessageSource] -
<Creating MessageFormat for pattern [New bulletin cannot be created
until conflicting bulletins from {} to {} are recalled.] and locale 'en'>
2010-05-08 15:28:21,362 ERROR
[org.springframework.web.servlet.tags.form.ErrorsTag] - <can't parse
argument number >
java.lang.IllegalArgumentException: can't parse argument number
       at java.text.MessageFormat.makeFormat(MessageFormat.java:1330)
       at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
       at java.text.MessageFormat.<init>(MessageFormat.java:368)
       at org.springframework.context.support.MessageSourceSupport.createMessageFormat(MessageSourceSupport.java:118)
       at org.springframework.context.support.ResourceBundleMessageSource.getMessageFormat(ResourceBundleMessageSource.java:277)
       at org.springframework.context.support.ResourceBundleMessageSource.resolveCode(ResourceBundleMessageSource.java:184)
       at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:205)

SOLUTION:
The error is occurring because the error message I'm using from messages.properties is:
admin.bulletin.previousBulletin.notRecalled = New bulletin cannot be created until conflicting bulletins from {} to {} are recalled.

when it should be:
admin.bulletin.previousBulletin.notRecalled = New bulletin cannot be created until conflicting bulletins from {0} to {1} are recalled.

No comments: