title: Spring application context is null
body: <p>I am using Spring Boot 1.3.3, with JavaFX. The application successfully launches Splash screen with this(at this point applicationContext is not null)</p>
  
  <pre><code>@SpringBootApplication
  public class PirconApplication extends Application{
  
  @Bean(name = "primaryStage")
  public Stage getPrimaryStage() {
      return new Stage(StageStyle.DECORATED);
  }
  
  private ConfigurableApplicationContext applicationContext = null;
  private static String[] args = null;
  
  @Override
  public void stop() throws Exception {
      super.stop();
      Platform.exit();
      applicationContext.close();
  }
  
  @Override
  public void start(Stage primaryStage) throws Exception {
      Task&lt;Object&gt; worker = worker();
      worker.setOnSucceeded(new EventHandler&lt;WorkerStateEvent&gt;() {
          @Override
          public void handle(WorkerStateEvent event) {
              try {
                  AppSplashController loader = applicationContext.getBean(AppSplashController.class);
                  Stage stage = applicationContext.getBean(Stage.class);
                  stage.setScene(loader.init());
                  stage.initStyle(StageStyle.UNDECORATED);
                  stage.show();
              } catch (IOException e) {
                      e.printStackTrace();
                      System.exit(0);
              }
          }
      });
      worker.setOnFailed(new EventHandler&lt;WorkerStateEvent&gt;() {
  
              @Override
              public void handle(WorkerStateEvent event) {
                      // TODO Auto-generated method stub
                      System.exit(0);
              }
      });
      worker.run();
  }
  public static void main(String[] args) {
      PirconApplication.args = args;
      launch(PirconApplication.class, args);
  }
  
  private Task&lt;Object&gt; worker() {
      return new Task&lt;Object&gt;() {
          @Override
          protected Object call() throws Exception {
                  applicationContext = SpringApplication.run(PirconApplication.class, args);
                  return null;
          }
      };
  }
  }
  </code></pre>
  
  <p>Problem is in AppSplashController applicationContext and primaryStage beans are all null.</p>
  
  <pre><code>@Component
  public class AppSplashController implements BootInitializable {
  
  @FXML
  private ImageView imgLoading;
  @FXML
  private Text lblWelcome;
  @FXML
  private Text lblRudy;
  @FXML
  private VBox vboxBottom;
  @FXML
  private Label lblClose;
  
  private Stage primaryStage;
  
  private ApplicationContext springContainer;
  /**
   * Initializes the controller class.
   */
  @Override
  public void initialize(URL url, ResourceBundle rb) {
      System.out.println("applicationContext: "+springContainer);
      System.out.println("primaryStage: "+primaryStage);
  }
  
  }
  
  @Autowired
  @Override
  public void setPrimaryStage(Stage primaryStage) {
      this.primaryStage = primaryStage;
  }
  
  @Override
  public Scene init() throws IOException {
      Parent root = FXMLLoader.load(getClass().getResource("/com/pircon/views/splash.fxml"));
      return new Scene(root);
  }
  
  @Override
  public void setApplicationContext(ApplicationContext ac) throws BeansException {
      this.springContainer = ac;
  }
  
  }
  </code></pre>
  
  <p>BootInitializable interface</p>
  
  <pre><code>public interface BootInitializable extends Initializable, ApplicationContextAware {
      public Scene init() throws IOException; 
      public void setPrimaryStage(Stage primaryStage);
  }
  </code></pre>
  
  <p>This is my first project in spring and spring boot, so pardon my ignorance.</p>