Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8118940

FXMLLoader fails with NPE when included fxml has a controler and parent hasn't

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 7u6
    • javafx
    • None

    Description

      If you have a child.fxml which has a controller which gets included into a parent.fxml which does not have one you get an NPE like this:
      Child controller created
      java.lang.NullPointerException
      /Users/tomschindl/Documents/e4_workspaces/efxclipse/testloader/bin/test/Parent.fxml:14
        at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2538)
        at javafx.fxml.FXMLLoader.access$1400(FXMLLoader.java:68)
        at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:946)
        at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:567)
        at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2313)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2130)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2027)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2741)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2720)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2706)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2693)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2682)
        at test.TestSubcontroller.start(TestSubcontroller.java:16)
        at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
        at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
        at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)

      java.lang.NullPointerException
      at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2538)
      at javafx.fxml.FXMLLoader.access$1400(FXMLLoader.java:68)
      at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:946)
      at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:567)
      at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2313)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2130)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2027)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2741)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2720)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2706)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2693)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2682)
      at test.TestSubcontroller.start(TestSubcontroller.java:16)
      at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
      at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)

      Attachments

        1. Child.fxml
          0.4 kB
        2. ChildController.java
          0.1 kB
        3. Parent.fxml
          0.4 kB
        4. TestSubcontroller.java
          0.7 kB

        Activity

          People

            gkbrown Greg Brown (Inactive)
            tschindl Tom Schindl
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: