0

I am currently facing an exception while loading the UI controller.

Have written two separate methods for testing client requests for a server while loading files.

I have start methods which loads UI controller-

@Override
public void start(Stage stage) throws IOException {

and test methods are as follows:

  1. First test

    @Test
    @DisplayName("load the files")
    public void testRoutineA() throws URISyntaxException, NullPointerException, IOException {
    
  2. Second test

    @Test
    public static void testRoutineB() throws IOException {
    

Issue:

  • testRoutineA runs fine and load the UI.
  • But when testRoutineB runs it again call the Sart method and throws exception:

Exception in Async Thread --- Failed to load FXML files.

Any suggestion how to use both methods ?

Slaw
  • 37,820
  • 8
  • 53
  • 80
  • 3
    Is there more to the error? How are you starting and stopping the JavaFX platform? Are you using _TestFX_? Instead of providing code snippets, can you provide a [mre]? – Slaw Aug 08 '22 at 16:13
  • I am using import org.testfx.framework.junit5.ApplicationTest; – chandrayog yadav Aug 08 '22 at 18:20
  • Error: --- Exception in Async Thread --- javafx.fxml.LoadException: /..../build/resources/main/com/../../UI/ImageUI.fxml javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707) – chandrayog yadav Aug 08 '22 at 18:21
  • 3
    Please [edit] your question to add more information. Comments are hard to read and cannot be formatted as elegantly. – Slaw Aug 08 '22 at 18:22
  • This is Start method: public void start(Stage stage) throws IOException { PlatformImpl.setImplicitExit(false); URL fxmlResource = this.getClass().getResource("../UI/ImageUI.fxml"); if (fxmlResource != null) { final var loader = new FXMLLoader(fxmlResource); final var mainApp = (Pane) loader.load(); controller = loader.getController(); stage.setScene(new Scene(mainApp, 1200, 1000)); stage.show(); stage.toFront(); } else { } } – chandrayog yadav Aug 08 '22 at 18:24
  • 2
    "Please [edit] your question to add more information. Comments are hard to read and cannot be formatted as elegantly."—@Slaw – trashgod Aug 08 '22 at 22:18

0 Answers0