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 <[EMAIL PROTECTED]> wrote:
Hi Matt,

In article <[EMAIL PROTECTED]>,
Tue, 15 Aug 2006 22:13:59 -0600,
"Matt Raible" <[EMAIL PROTECTED]> 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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to