jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Raible" <mrai...@gmail.com>
Subject Re: Cactus 1.7.2 setting the wrong locale?
Date Wed, 16 Aug 2006 13:37:54 GMT
The problem was that the following only loads the context files
specified by ContextLoaderListener.

       ApplicationContext ctx =
           WebApplicationContextUtils
               .getRequiredWebApplicationContext(
                   session.getServletContext());

In early versions of Spring (1.1.x series), the above line would have
the beans loaded by Spring's DispatcherServlet as well.  This seems to
have changed since 1.2.x, and therefore, I had to mock out any beans I
expected to be in this context. Here's what my new setUp() method
looks like:

    protected void setUp() throws Exception {
        super.setUp();
        ApplicationContext ctx =
            WebApplicationContextUtils
                .getRequiredWebApplicationContext(
                    session.getServletContext());
        UserManager userManager =
            (UserManager) ctx.getBean("userManager");
        list.setUserManager(userManager);
        form.setUserManager(userManager);

        // needed to prevent NPE with getMessageSourceAccessor()
        StaticApplicationContext staticCtx = new StaticApplicationContext();
        Map properties = new HashMap();
        properties.put("basename", "messages");
        staticCtx.registerSingleton("messageSource",
                              ResourceBundleMessageSource.class,
                              new MutablePropertyValues(properties));
        staticCtx.refresh();
        form.setApplicationContext(staticCtx);
    }

Matt

On 8/16/06, Kazuhito SUGURI <suguri.kazuhito@lab.ntt.co.jp> wrote:
> Hi Matt,
>
> In article <7feebe1f0608152113n62213d5aybe54464995047125@mail.gmail.com>,
> Tue, 15 Aug 2006 22:13:59 -0600,
> "Matt Raible" <mraible@gmail.com> wrote:
> mraible> I managed to solve this problem - thanks for your help.
>
> What was the cause?
> Your feedback would be informative for other Spring users
> in this community.
>
> Best Regards,
> ----
> Kazuhito SUGURI
>

Mime
View raw message