mardi 30 septembre 2014

Accessing message.properties works in development but not when deployed


Vote count:

0




The following code works fine when deployed locally in a dev environment from a controller (using run-app). It's used to create a JavaScript object with all messages in the current language.



class LocaleController {
private Map<String, String> getMessages() {
// This is the line in question, the rest is just context
def bundle = ResourceBundle.getBundle("grails-app/i18n/messages");
def map = [:]
bundle.keys.each { msg ->
map[msg] = message(code: msg)
}
return map
}

def index() {
header("Cache-Control", "public, max-age=31536000")
render(view: "index", model: [messages: getMessages()], contentType: "text/javascript")
}
}


However, when this is run from a deployed server, I get the following error message



errors.GrailsExceptionResolver - MissingResourceException occurred when processing request: [GET] /compose/locale/index Can't find bundle for base name grails-app/i18n/messages, locale en_US. Stacktrace follows: java.util.MissingResourceException: Can't find bundle for base name grails-app/i18n/messages, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322) at java.util.ResourceBundle.getBundle(ResourceBundle.java:1028) at com.accelrys.compose.app.LocaleController.getMessages(LocaleController.groovy:13) at com.accelrys.compose.app.LocaleController.index(LocaleController.groovy...



I would have preferred not to read the file directly, so I tried http://ift.tt/1uZSrqH which uses http://ift.tt/1rq4K1K but that page has been offline for the past 10 days.


I also tried following the steps in How can I create a map with all i18n-messages in Grails but it wouldn't use my customized message source, I copied the answer verbatim (clean/comile/run-app) but it was still using PluginAwareResourceBundleMessageSource instead of ExtendedPluginAwareResourceBundleMessageSource


Any suggestions on what else I can try?



asked 1 min ago







Accessing message.properties works in development but not when deployed

Aucun commentaire:

Enregistrer un commentaire