title: "javafx.fxml.LoadException" when loading fxml
body: <p>The error is being produced at showAdminLoginScene() method,
  However if I modify this method and I put another fxml file from the same package to load, it loads just fine :  here's my Main : </p>
  
  <pre><code>package application;
  
  import java.io.IOException;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.layout.AnchorPane;
  import javafx.scene.layout.BorderPane;
  import javafx.stage.Stage;
  
  public class Main extends Application {
    private Stage primaryStage;
    private static BorderPane mainLayout;
    @Override
  public void start(Stage primaryStage) throws IOException {
      this.primaryStage= primaryStage;
      this.primaryStage.setTitle("LAU LABS");
      showMainView();
  }
  private void showMainView() throws IOException{
      FXMLLoader loader=new FXMLLoader();
      loader.setLocation(Main.class.getResource("MainView.fxml"));
  
      mainLayout=loader.load();
  
  
      Scene scene=new Scene(mainLayout);
      primaryStage.setScene(scene);
      primaryStage.show();
  }
  
  public static void showAdminLoginScene() {
      FXMLLoader loader=new FXMLLoader();
      loader.setLocation(Main.class.getResource("AdminLogin.fxml"));
      BorderPane adminLogin;
      try {
          adminLogin = loader.load();
          mainLayout.setCenter(adminLogin);
          } catch (IOException e) {
          e.printStackTrace();
      }
  
  }
  public static void showAdminLoggedIn() {
      FXMLLoader loader=new FXMLLoader();
      loader.setLocation(Main.class.getResource("AdminLoggedIn.fxml"));
      AnchorPane adminLoggedIn;
      try {
          adminLoggedIn = loader.load();
          mainLayout.setCenter(adminLoggedIn);
      } catch (IOException e) {
          System.out.println("the error is in Main, ShowAdminLoggedIn");
      }
  
  }
  public static void main(String[] args) {
      launch(args);
  }
  }
  </code></pre>
  
  <p>And here's my controller class : </p>
  
  <pre><code>package application;
  
  import java.awt.Label;
  import java.awt.TextField;
  import java.awt.event.ActionEvent;
  import java.io.IOException;
  
  import javafx.fxml.FXML;
  
  
  public class AdminLoginController {
     @FXML private TextField txtUsername;
     @FXML private TextField txtPassword;
     @FXML private Label lblStatus;
     private Main main;
  
  
  public void Login(ActionEvent event) {
     if(txtUsername.getText().equals("user")&amp;&amp; 
           txtPassword.getText().equals("pass")){
      main.showAdminLoggedIn();
  }
  else{
      lblStatus.setText("Login Failed!");
  }
  }
  }
  </code></pre>
  
  <p>Here's my fxml : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import com.gluonhq.charm.glisten.control.TextField?&gt;
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.control.PasswordField?&gt;
  &lt;?import javafx.scene.image.Image?&gt;
  &lt;?import javafx.scene.image.ImageView?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  &lt;?import javafx.scene.layout.BorderPane?&gt;
  &lt;?import javafx.scene.text.Text?&gt;
  
  
  &lt;BorderPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.AdminLoginController"&gt;
     &lt;center&gt;
        &lt;AnchorPane prefHeight="300.0" prefWidth="300.0"&gt;
           &lt;children&gt;
              &lt;TextField fx:id="txtUsername" layoutX="56.0" layoutY="79.0" prefHeight="26.0" prefWidth="189.0" /&gt;
              &lt;PasswordField fx:id="txtPassword" layoutX="56.0" layoutY="150.0" prefHeight="26.0" prefWidth="189.0" /&gt;
              &lt;Button layoutX="56.0" layoutY="227.0" mnemonicParsing="false" onAction="#Login" prefHeight="32.0" prefWidth="189.0" style="-fx-background-color: #004c3c;" text="Login" /&gt;
              &lt;Text fill="#004c3c" layoutX="56.0" layoutY="75.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Username" wrappingWidth="60.98307228088379" /&gt;
              &lt;Text fill="#004c3c" layoutX="56.0" layoutY="146.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Password" /&gt;
              &lt;Button layoutX="1.0" minWidth="52.0" mnemonicParsing="false" prefHeight="39.0" prefWidth="52.0" style="-fx-background-color: Transparent;" /&gt;
              &lt;ImageView fitHeight="35.0" fitWidth="200.0" layoutX="10.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true"&gt;
                 &lt;image&gt;
                    &lt;Image url="@BackButton.png" /&gt;
                 &lt;/image&gt;
              &lt;/ImageView&gt;
              &lt;Label fx:id="lblStatus" layoutX="56.0" layoutY="202.0" prefHeight="16.0" prefWidth="189.0" style="-fx-text-fill: Red;" text="Status: " /&gt;
           &lt;/children&gt;
        &lt;/AnchorPane&gt;
     &lt;/center&gt;
  &lt;/BorderPane&gt;
  </code></pre>
  
  <p>They're all in the same package named "application" (the fxml, controller and main)</p>
  
  <p>That's the error : </p>
  
  <pre><code>javafx.fxml.LoadException: 
  /C:/Users/Owner/Documents/UNI/programming/workspace/Lau/bin/application/AdminLogin.fxml
  
      at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
      at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2848)
      at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
      at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
      at application.Main.showAdminLoginScene(Main.java:39)
      at application.MainViewController.goAdminLogin(MainViewController.java:8)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at sun.reflect.misc.Trampoline.invoke(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
      at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
      at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
      at javafx.event.Event.fireEvent(Event.java:198)
      at javafx.scene.Node.fireEvent(Node.java:8413)
      at javafx.scene.control.Button.fire(Button.java:185)
      at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
      at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
      at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
      at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
      at javafx.event.Event.fireEvent(Event.java:198)
      at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
      at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
      at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
      at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
      at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
      at com.sun.glass.ui.View.notifyMouse(View.java:937)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.TextField
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
      at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
      at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
      ... 65 more
  </code></pre>