I am building javafx application in which i am trying to load .fxml file using FXMLLoader
. Doing so, it throws IllegalAccessError
Without FXMLLoader
application runs fine. I am using Maven tool and dependencies are included:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
Overriden start method:
@Override
public void start(Stage primaryStage) throws Exception
{
System.out.println(getClass().getResource(""));
URL url = getClass().getResource("fxml/defaultScene.fxml");
Scene scene = new Scene(FXMLLoader.load(url)); // <- exception occurs here
ViewController viewController = new ViewController(scene);
module-info.java:
module DesktopApp
{
exports core;
requires javafx.graphics;
requires javafx.fxml;
}
Exception:
java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelpe
r (in unnamed module @0x67583cb) cannot access class com.sun.javafx.scene.layout.RegionHelper (in module javafx.graphics
) because module javafx.graphics does not export com.sun.javafx.scene.layout to unnamed module @0x67583cb