0

Here is the error message:

javafx.fxml.LoadException: /C:/Dev/git/luna-WB_10-14/WebdriverGUI/bin/Gui.fxml

at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at application.Main.start(Main.java:19)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1743635185.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$44/1051754451.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/499162309.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/1775282465.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at application.MainInit.initialize(MainInit.java:89)
... 23 more

Here is the MainInit Class:

package application;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import org.junit.runner.JUnitCore;
import otherlinescommon.OLCommon;
import com.shelter.webdriver.otherlines.test.TestNewBusiness;
import com.shelter.webdriver.otherlines.test.TestNewBusinessGUI;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Cursor;
import javafx.scene.control.Accordion;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TitledPane;
import javafx.scene.control.Tooltip;
import javafx.scene.input.MouseEvent;

public class MainInit  extends MainVariables implements Initializable
{
/**
 * Variables are all located in MainVariables class
 * All methods are located in MainMethods class
 */

@Override
public void initialize(URL location, ResourceBundle resources)
{
    /**
     * Accordion setup
     */
    masterAccordion.setExpandedPane(tnbPane);

line 89 below
combo_enb_environment.setItems(FXCollections.observableArrayList(
            "Devl", "Unit", "Test", "Modl"));
combo_enb_environment.setValue("Devl");
combo_enb_environment.setTooltip(new Tooltip(
            "Select the environment to run the tests in"));
combo_enb_environment.getSelectionModel().getSelectedItem();

Here is the variable initialization from MainVariables Class:

@FXML
protected static ChoiceBox<String> combo_enb_environment;

I am not sure why this nullpointer is throwing on the setItems() call because when I debug the FXCollections.observableArrayList() is populated. Can anyone lend some insight as to how this can be fixed?

Swagin9
  • 1,002
  • 13
  • 24
  • Check for your `combo_enb_environment`. I guess it is not correctly initialized. – ItachiUchiha Oct 15 '14 at 13:48
  • possible duplicate of [javafx 8 compatibility issues - FXML static fields](http://stackoverflow.com/questions/23105433/javafx-8-compatibility-issues-fxml-static-fields) – James_D Oct 15 '14 at 14:23
  • @ItachiUchiha You were correct. It wasn't initialized properly. Updated code to display: FXML protected static ChoiceBox combo_end_environment = new ChoiceBox(); – Swagin9 Oct 15 '14 at 14:48
  • 1
    That won't do what you want. The fix is not to make it static. You should also **never** initialize `@FXML`-injected fields. – James_D Oct 15 '14 at 18:49
  • @James_D Do you have another suggestion as to what might fix the problem then? Do the FXML-injected fields need to be moved to the MainInit class then, instead of having a separate class for them? – Swagin9 Oct 15 '14 at 20:23
  • Just take out `static`. You never want a UI control in a controller class to be static (what if you load the FXML twice, for example)? See http://stackoverflow.com/questions/23105433/javafx-8-compatibility-issues-fxml-static-fields – James_D Oct 15 '14 at 20:27
  • @James_D taking out static throws that error again though. – Swagin9 Oct 15 '14 at 20:28
  • Try (perhaps temporarily) moving it to the subclass to see if that's the issue. I remember there was a question about injecting fields into a superclass but I'm stuck on a phone now and can't find it. (I assume you have checked the fx:id attribute is correct.) – James_D Oct 15 '14 at 20:48
  • Hi @James_D, after some more research I think the problem might be caused by developing the application in jdk 7 and then trying to run it with jdk 8 now. Also, do you know of any way to use fields in an event since the overridden handle method is static, therefore requires static variables to be used? – Swagin9 Oct 22 '14 at 18:10
  • Which method is static? – James_D Oct 22 '14 at 18:43

0 Answers0