title: Why I'm getting javafx.fxml.LoadException even the path of the fxml file is correct
body: <p>I get</p>
  
  <blockquote>
    <p>javafx.fxml.LoadException:</p>
  </blockquote>
  
  <p>When I'm loading and fxml file using following line of code.</p>
  
  <blockquote>
    <p>AnchorPane anchorPane = (AnchorPane)loader.load()</p>
  </blockquote>
  
  <p>This is my fxml file excluding import statements.</p>
  
  <pre><code>&lt;AnchorPane prefHeight="537.0" prefWidth="374.0"     xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.buddhikajay.controller.NewTransactionDialogController"&gt;
     &lt;children&gt;
        &lt;GridPane hgap="5.0" layoutX="30.0" layoutY="10.0" prefHeight="544.0" prefWidth="314.0" vgap="5.0"&gt;
      &lt;columnConstraints&gt;
        &lt;ColumnConstraints hgrow="SOMETIMES" maxWidth="142.0" minWidth="10.0" prefWidth="69.0" /&gt;
        &lt;ColumnConstraints hgrow="SOMETIMES" maxWidth="226.0" minWidth="10.0" prefWidth="225.0" /&gt;
      &lt;/columnConstraints&gt;
      &lt;rowConstraints&gt;
        &lt;RowConstraints maxHeight="70.0" minHeight="10.0" prefHeight="33.0" vgrow="SOMETIMES" /&gt;
        &lt;RowConstraints maxHeight="105.0" minHeight="10.0" prefHeight="38.0" vgrow="SOMETIMES" /&gt;
        &lt;RowConstraints maxHeight="156.0" minHeight="10.0" prefHeight="51.0" vgrow="SOMETIMES" /&gt;
          &lt;RowConstraints maxHeight="154.0" minHeight="10.0" prefHeight="43.0" vgrow="SOMETIMES" /&gt;
          &lt;RowConstraints maxHeight="160.0" minHeight="10.0" prefHeight="43.0" vgrow="SOMETIMES" /&gt;
          &lt;RowConstraints maxHeight="161.0" minHeight="10.0" prefHeight="63.0" vgrow="SOMETIMES" /&gt;
          &lt;RowConstraints maxHeight="301.0" minHeight="10.0" prefHeight="180.0" vgrow="SOMETIMES" /&gt;
          &lt;RowConstraints maxHeight="231.0" minHeight="10.0" prefHeight="106.0" vgrow="SOMETIMES" /&gt;
      &lt;/rowConstraints&gt;
       &lt;padding&gt;
          &lt;Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /&gt;
       &lt;/padding&gt;
       &lt;children&gt;
          &lt;Label text="ID" /&gt;
          &lt;Label text="Date" GridPane.rowIndex="1" /&gt;
          &lt;Label text="Amont" GridPane.rowIndex="2" /&gt;
          &lt;Label text="Person" GridPane.rowIndex="4" /&gt;
          &lt;Label text="Type" GridPane.rowIndex="3" /&gt;
          &lt;Label text="Resolved" GridPane.rowIndex="5" /&gt;
          &lt;Label /&gt;
          &lt;Label text="Description" GridPane.rowIndex="6" /&gt;
          &lt;TextField fx:id="idTextField" GridPane.columnIndex="1" /&gt;
          &lt;TextField fx:id="dateTextField" GridPane.columnIndex="1" GridPane.rowIndex="1" /&gt;
          &lt;TextField fx:id="amountTextField" GridPane.columnIndex="1" GridPane.rowIndex="2" /&gt;
          &lt;TextArea fx:id="descriptionTextArea" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="6" /&gt;
          &lt;HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="50.0" prefWidth="225.0" spacing="20.0" GridPane.columnIndex="1" GridPane.rowIndex="7"&gt;
             &lt;GridPane.margin&gt;
                &lt;Insets /&gt;
             &lt;/GridPane.margin&gt;
             &lt;padding&gt;
                &lt;Insets bottom="10.0" left="20.0" right="10.0" top="10.0" /&gt;
             &lt;/padding&gt;
             &lt;children&gt;
                &lt;Button fx:id="okButton" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#okActionFired" prefHeight="25.0" prefWidth="75.0" text="Ok" /&gt;
                &lt;Button fx:id="cancleButton" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#cancleActionFired" prefHeight="25.0" prefWidth="75.0" text="Cancle" /&gt;
             &lt;/children&gt;
          &lt;/HBox&gt;
          &lt;ComboBox fx:id="typeComboBox" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="3" /&gt;
          &lt;ComboBox fx:id="personComboBox" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="4" /&gt;
          &lt;ComboBox fx:id="resolvedComboBox" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="5" /&gt;
       &lt;/children&gt;
    &lt;/GridPane&gt;
    &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>The compiler complains that there is an error in line number 1. I'm sure that the path of fxml file is correct. What is wrong with my code?</p>
  
  <p>Here is the full error stack</p>
  
  <pre><code>javafx.fxml.LoadException: 
  /C:/Users/Buddhika/Documents/Programming/IdeaProjects/VirtualCreditDesktop/out/production/VirtualCreditDesktop/com/buddhikajay/view/NewTransactionDialog.fxml:9
  
      at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2595)
      at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104)
      at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:928)
      at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
      at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
      at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
      at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2701)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2521)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2435)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2403)
      at com.buddhikajay.controller.NewTransactionDialogController.showNewTransactionDialog(NewTransactionDialogController.java:68)
      at com.buddhikajay.controller.MainApp.start(MainApp.java:51)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
      at com.sun.javafx.application.LauncherImpl$$Lambda$50/1976027283.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
      at com.sun.javafx.application.PlatformImpl$$Lambda$46/301541210.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
      at com.sun.javafx.application.PlatformImpl$$Lambda$48/474926796.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
      at com.sun.javafx.application.PlatformImpl$$Lambda$47/1662429848.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
      at com.sun.glass.ui.win.WinApplication$$Lambda$38/519284171.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.InstantiationException: com.buddhikajay.controller.NewTransactionDialogController
      at java.lang.Class.newInstance(Class.java:423)
      at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
      at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
      ... 23 more
  Caused by: java.lang.NoSuchMethodException: com.buddhikajay.controller.NewTransactionDialogController.&lt;init&gt;()
      at java.lang.Class.getConstructor0(Class.java:3074)
      at java.lang.Class.newInstance(Class.java:408)
      ... 25 more
  </code></pre>