action = actionService.createAction(SampleAction.NAME) action.setParameterValue(SampleAction.PARAM_QUERY, query) action.setExecuteAsynchronously(true) // here is the problem when async is true actionService.executeAction(action, null)
Strange thing happens with asynchronous execution.
In code we try to retrieve localized messages from I18NUtil:
I18NUtil.getMessage("action.sample.msg") // or messageService.getMessage("action.sample.msg")
When action is called with asynchronous=false -> everything is alright.
But when asynchronous=true -> I18NUtil or even messageService can not find the message (returns null)
I've tried debug through I18NUtil.getMessage() - seems that budles are there with messages, but can not retrieve the exact message
Status report: we debugged I18NUtil a little bit more: when called from the asynchronous action - our custom budles are cached, but messages from this context are not (not even one message from our custom bundles)
Your problem probably has to do with the lack of the proper Locale in the context of I18nUtil. When you run an action in synchronous mode, the action and I18nUtil inherit the Locale context from the request thread, which typically is associated with the Locale as provided by the client browser. This context is not carried over to asynchronous actions, and as such, the I18nUtil may try to look up messages in different locales from the ones for which you have provided message bundles, and thus not find any matches.