Declare as ConfigurableApplicationContext to avoid the casts below.