Java FX создание fxmlUrl выдает null

всем добрый день, пытаюсь стартануть приложение, но почему-то не может подгрузиться путь до файла

@Override
public void start(Stage primaryStage) throws Exception {
    URL fxmlUrl = getClass().getClassLoader().getResource("view/WeatherView.fxml");
    System.out.println(fxmlUrl);
    //вот тут выкидывается null
    AnchorPane root = FXMLLoader.load(fxmlUrl);
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle("MyWeather");
    primaryStage.centerOnScreen();
    primaryStage.setResizable(false);
    primaryStage.setOpacity(0.9);
    primaryStage.show();
}

сам WeatherView.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="200.0" prefWidth="400.0" styleClass="mainFxmlClass"
            xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.WeatherController">
    <stylesheets>
        <URL value="@WeatherStyle.css"/>
    </stylesheets>
    <HBox spacing="20" alignment="BASELINE_CENTER" AnchorPane.topAnchor="10.0"
          AnchorPane.leftAnchor="10.0">
        <fx:define>
            <ToggleGroup fx:id="cityTg"/>
        </fx:define>
        <children>
            <RadioButton text="Bajina Basta" toggleGroup="$cityTg" selected="true"/>
            <RadioButton text="Belgrade" toggleGroup="$cityTg"/>
            <RadioButton text="Zrenjanin" toggleGroup="$cityTg"/>
            <Button fx:id="refreshBtn" onAction="#initialize" />
        </children>
    </HBox>
    <Label fx:id="iconLbl" AnchorPane.topAnchor="50.0" />
    <Label fx:id="cityNameLbl" AnchorPane.topAnchor="100.0" AnchorPane.leftAnchor="10.0"/>
    <Label fx:id="descriptionLbl" AnchorPane.topAnchor="130.0" AnchorPane.leftAnchor="10.0"/>
    <Label fx:id="temperatureLbl" AnchorPane.topAnchor="50.0" AnchorPane.leftAnchor="60.0"/>
    <Label fx:id="celsiusLbl" text="°C" AnchorPane.topAnchor="68.0" AnchorPane.leftAnchor="150.0"/>
    <Label text="P:" AnchorPane.topAnchor="50.0" AnchorPane.leftAnchor="200.0" />
    <Label text="mbar" AnchorPane.topAnchor="50.0" AnchorPane.leftAnchor="280.0" />
    <Label fx:id="pressureLbl" AnchorPane.topAnchor="50.0" AnchorPane.leftAnchor="230.0"/>
    <Label text="H:" AnchorPane.topAnchor="70.0" AnchorPane.leftAnchor="200.0" />
    <Label text="\%" AnchorPane.topAnchor="70.0" AnchorPane.leftAnchor="280.0" />
    <Label fx:id="humidityLbl" AnchorPane.topAnchor="70.0" AnchorPane.leftAnchor="230.0"/>
    <Label text="W:" AnchorPane.topAnchor="90.0" AnchorPane.leftAnchor="200.0" />
    <Label text="kmph" AnchorPane.topAnchor="90.0" AnchorPane.leftAnchor="280.0" />
    <Label fx:id="windLbl" AnchorPane.topAnchor="90.0" AnchorPane.leftAnchor="230.0"/>
    <Label fx:id="timeLbl" AnchorPane.topAnchor="130.0" AnchorPane.leftAnchor="200.0" />
    <HBox fx:id="botBox" prefWidth="400.0" spacing="20" alignment="BASELINE_CENTER" AnchorPane.bottomAnchor="0.0"
          AnchorPane.leftAnchor="0.0">
        <children>
            <Label fx:id="djoLbl" text="   Djordje Gavrilovic 2017" />
            <Label fx:id="owmLbl" text="Powered by OpenWeatherMap" />
        </children>
    </HBox>
</AnchorPane>

и вот само исключение

Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at controller.WeatherController.start(WeatherController.java:94)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
    ... 1 more
Exception running application controller.WeatherController

[1]: https://i.stack.imgur.com/TUtZf.png - иерархия классов


Ответы (0 шт):