google-code-export / slim3

Automatically exported from code.google.com/p/slim3
1 stars 1 forks source link

Crash when Locale not supported #53

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install the blank application (version 1.0.5 for mine)
2. Add a controller
3. Launch the server
4. Set your browser Locale to any Locale not implemented (other than ja and en)
5. Visit your beautifull application
6. Error message : Can't find bundle for base name application, locale 
7. Set your browser Locale back to en or ja
8. Refresh your browser
9. Page works perfectly

What is the expected output? What do you see instead?
Application should not crash when a user with an unexpected Locale comes by but 
should default to a predefined locale.

What version of the product are you using? On what operating system?
Using slim3-blank version 1.0.5, with eclipse and google plugins on debian.

Please provide any additional information below.
Complete stack trace :
java.util.MissingResourceException: Can't find bundle for base name 
application, locale fr
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1539)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1278)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:980)
    at org.slim3.util.ResourceBundleApplicationMessageDelegate.setBundle(ResourceBundleApplicationMessageDelegate.java:44)
    at org.slim3.util.ApplicationMessage.setBundle(ApplicationMessage.java:63)
    at org.slim3.controller.FrontController.doFilter(FrontController.java:343)
    at org.slim3.controller.FrontController.doFilter(FrontController.java:308)
    at org.slim3.controller.FrontController.doFilter(FrontController.java:270)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.slim3.datastore.DatastoreFilter.doFilter(DatastoreFilter.java:54)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.slim3.controller.HotReloadingFilter.doHotReloading(HotReloadingFilter.java:223)
    at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:187)
    at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

Original issue reported on code.google.com by det...@gmail.com on 26 Oct 2010 at 9:26

GoogleCodeExporter commented 9 years ago

Original comment by higaya...@gmail.com on 3 Nov 2010 at 9:28

GoogleCodeExporter commented 9 years ago
Any workaround?

I got the same error:

HTTP ERROR 500
Problem accessing /. Reason:
Can't find bundle for base name application, locale pt_BR

Any workaround?

Thanks

Original comment by danielba...@gmail.com on 16 Nov 2010 at 1:45

GoogleCodeExporter commented 9 years ago
Please define application.properites whose language is yours as a workaround.

Original comment by higaya...@gmail.com on 16 Nov 2010 at 3:10

GoogleCodeExporter commented 9 years ago
Maybe slim3 should choose Locale "en" bundle as fallback, if browser defined 
Locale is not available. 

Original comment by rsaccon on 16 Nov 2010 at 12:04

GoogleCodeExporter commented 9 years ago
I will fix the problem in such a way.

Original comment by higaya...@gmail.com on 16 Nov 2010 at 1:08

GoogleCodeExporter commented 9 years ago

Original comment by higaya...@gmail.com on 29 Nov 2010 at 12:42

GoogleCodeExporter commented 9 years ago
I updated Slim3 to version 1.0.6, but the application continues crashing when a 
user comes with an unexpected Locale.

I still had to create an application.properties file (workaround).

java.util.MissingResourceException: Can't find bundle for base name 
application, locale pt_BR

Original comment by danvas...@gmail.com on 7 Feb 2011 at 3:01

GoogleCodeExporter commented 9 years ago
Sorry for the inconvenient.
I cannot reproduce this issue on my environment.
But I fixed the source as follows:
public void setBundle(String bundleName, Locale locale)
            throws NullPointerException {
    if (bundleName == null) {
        throw new NullPointerException("The bundleName parameter is null.");
    }
    if (locale == null) {
        throw new NullPointerException("The locale parameter is null.");
    }
    try {
        bundles.set(ResourceBundle.getBundle(bundleName, locale, Thread
                .currentThread()
                .getContextClassLoader()));
    } catch (MissingResourceException ignore) {
        bundles.set(ResourceBundle.getBundle(
                bundleName,
                Locale.ENGLISH,
                Thread.currentThread().getContextClassLoader()));
    }
}

Original comment by higaya...@gmail.com on 7 Feb 2011 at 3:27

GoogleCodeExporter commented 9 years ago
I tested with this new code and now its not crashing anymore. Problem solved.

Thanks.

Original comment by danvas...@gmail.com on 7 Feb 2011 at 10:09