java.lang.RuntimeException: java.lang.reflect.InvocationTargetException




I get a NullPointerException when I run the following program. Please note that I'm using Hibernate.


I can't figure out how to fix the Null Pointer error. This is the error:



```
Caused by: java.lang.NullPointerException
    at wakiliproject.SampleController.setSettersLose(SampleController.java:22)

```

The KIWI\_TABLE is created in the database by this class:



```
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity(name = "KIWI_TABLE")
public class NewBeautifulKiwi implements Serializable {

    @Id
    @GeneratedValue
    private int KiwiId;
    private String Kiwi;

    public int getKiwiId() {
        return KiwiId;
    }

    public void setKiwiId(int KiwiId) {
        this.KiwiId = KiwiId;
    }

    public String getKiwi() {
        return Kiwi;
    }

    public void setKiwi(String Kiwi) {
        this.Kiwi = Kiwi;
    }
}

```

This is how I call the NewBeautifulKiwi to persist items into the table 'KIWI\_TABLE':
(partial extract of the class)



```
public class SampleController implements Initializable, ControlledScreen {

    @FXML
    TextField KIWITextField;

    @FXML
    public void setSettersLose () {
        NewBeautifulKiwi newBeautifulKiwi = new NewBeautifulKiwi();
        newBeautifulKiwi.setKiwi(KIWITextField.getText());

        SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
        Session session = sessionFactory.openSession();
        session.beginTransaction();
        session.save(newBeautifulKiwi);
        session.getTransaction().commit();
    }

```

More of the error:



```
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1449)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
    at javafx.event.Event.fireEvent(Event.java:171)
    at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3100)
    at javafx.scene.Scene$ClickGenerator.access$8600(Scene.java:3038)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3320)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3151)
    at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3106)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2248)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:530)
    at com.sun.glass.ui.View.notifyMouse(View.java:924)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1446)
    ... 30 more
Caused by: java.lang.NullPointerException
    at wakiliproject.SampleController.setSettersLose(SampleController.java:23)
    ... 40 more

```

Thank you in advance.


EDIT: The SampleController Class with everything else:



```
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import wakiliproject.Forms.AddNew.DB.NewBeautifulKiwi;

public class SampleController implements Initializable, ControlledScreen {

    @FXML
    TextField KIWITextField = null;

    @FXML
    public void setSettersLose () {
        NewBeautifulKiwi newBeautifulKiwi = new NewBeautifulKiwi();
        newBeautifulKiwi.setKiwi(KIWITextField.getText());

        SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
        Session session = sessionFactory.openSession();
        session.beginTransaction();
        session.save(newBeautifulKiwi);
        session.getTransaction().commit();
    }   

    ScreensController myController;

    // Initializes the controller class.
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }

    @Override
    public void setScreenParent(ScreensController screenParent) {
        myController = screenParent;
    }

    @FXML
    public void windowClose() {
        Platform.exit();
    }

    // Pages
    @FXML
    private void goToClients() {
        myController.setScreen(WakiliProject.clientsID);
    }

    @FXML
    private void goToMatters() {
        myController.setScreen(WakiliProject.mattersID);
    }

    @FXML
    private void goToEvents() {
        myController.setScreen(WakiliProject.eventsID);
    }

    @FXML
    private void goToFirmProfileView() {
        myController.setScreen(WakiliProject.firmProfileID);
    }

    // Hover menus
    @FXML
    Pane clientAccountsHoverMenu;

    @FXML
    private void clientAccountsHover() {
        clientAccountsHoverMenu.setVisible(true);
    }

    @FXML
    private void clientAccountsHoverOut() {
        clientAccountsHoverMenu.setVisible(false);
    }

    // Hidden Panes
    @FXML
    Pane notesHomePane;

    @FXML
    Pane navItems;

    @FXML
    Pane mainHome;

    @FXML
    Pane homeContentDisplay;

    @FXML
    private void notesHomePaneShow() {
        notesHomePane.setVisible(true);
        mainHome.setVisible(false);
    }

    @FXML
    private void goToHome() {
        notesHomePane.setVisible(false);
        mainHome.setVisible(true);
    }

    @FXML
    private void navItemsShow() {
        navItems.setVisible(true);
        homeContentDisplay.setVisible(false);
    }

    @FXML
    private void goToHomeFronNavAll() {
        navItems.setVisible(false);
        homeContentDisplay.setVisible(true);
    }
}

```
So since the line of interest is `newBeautifulKiwi.setKiwi(KIWITextField.getText());` and taking into account that `newBeautifulKiwi` can never be null (it has just been created using default constructor) it's `KIWITextField` that is null and thus not inject properly. make sure the id of this element in .fxml file ***exactly*** matches this field's name (I'd made it private).


Most probable cause is `setSettersLose` annotated with @FXML. Check the [similar thread](https://stackoverflow.com/questions/14017542/how-do-i-change-fxml-controller-variable-values-in-javafx-before-showing-window).
that error happens when there's no handle to close. i see you call the 'open()' and you're not getting an object reference error before closehandle(). check your memory.pointerwrite() function to make sure it's not doing a closehandle() prematurely. it sounds like you're calling closehandle() twice. for posterity, the issue was a different environment was being used in the ijulia notebook, which contained pavito, causing jump to downgrade.

for others finding this, here is the documentation on pkg environments:

[image]

[4. working with environments · pkg.jl](https://julialang.github.io/pkg.jl/v1/environments/) looking around i think i found the answer myself.

there is are batch and script files in jabref/runtime/bin.

from those, the needed command line call can be derived. using the shipped jvm from inside the mentioned folder the call i looked for would be:

java --add-opens=javafx.controls/javafx.scen… hi [@gianna.demetroulakos](/u/gianna.demetroulakos),

as mentioned by [@william.coulson](/u/william.coulson), the object reference not set to an instance of an object normally occurs when a variable is null.

run the code in the debug mode.

when the error occurs, check the variable which has a null value in locals tab.

warm regards,

ranjith u… hey [@jsteb](/u/jsteb), i was struggling with this and i figured what is going on. the problem is with the action button. if you try with a regular button it will work. i think that should be clarified in the tutorial Found it…Check out this link [Error 26630.](https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk106641)



Basically user does not have permissions to run the install. hi,

do you have joy package installed with all necessary packages/dependencies ?

try to search for joy\_node or run joy package examples to find out what is going wrong. hey [@emartini](/u/emartini) ,

if you want to use clij2, you also need to activate the clij update site. the error should be gone then.

[[image]](https://aws1.discourse-cdn.com/business4/uploads/imagej/original/3x/0/9/095bc5fb3f3fa0db9dac6286bb16cf30ee81783d.jpeg "image")

see also the [installation instructions](https://clij.github.io/clij2-docs/installationinfiji).

let me know if this solves the issue!

cheers,

robert use promise.allsettled(). the following code works, it's simply going to skip over the rejected promise:
```javascript
function getwikiprofiles(data) {
 const profiles = data.people.map(person => {
 return getjson(wikiurl + person.name);
 });
 return promise.allsettled(profiles);
}
function generatehtml(data) {
 //console.log(data);
 data.foreach(person => {
 if (person.status  'fulfilled') {
 person = person.value;
 const section = document.createelement('section');
 peoplelist.appendchild(section);
 section.innerhtml = 
 ![](%24%7bperson.thumbnail.source%7d)
${person.title}



${person.description}


${person.extract}


;
 }
 });
``` Resolved:  

  

FORM 1.  

  

Copy Code

```
private void btnModificaContractul\_Click(object sender, EventArgs e)
        {


            string[] IDProdusContractPrelugit = new string[dataProduseContract.Rows.Count];
            string[] IDProdusContractRetras = new string[dataProduseContract.Rows.Count];

            for (int i = 0; i < dataProduseContract.Rows.Count; i++)
            {

                if (Convert.ToBoolean(dataProduseContract.Rows[i].Cells[0].Value) == false)
                {
                    IDProdusContractPrelugit[i] = dataProduseContract.Rows[i].Cells[5].Value.ToString();
                }
                else
                {
                    IDProdusContractRetras[i] = dataProduseContract.Rows[i].Cells[5].Value.ToString();
                }
            }

           

            try
            {
                frmModificaContract ModificareContract = new frmModificaContract(IDProdusContractPrelugit, IDProdusContractRetras);
                ModificareContract.ShowDialog();
            }
            catch { MessageBox.Show("Trebuie să selectaţi un contract din listă pentru a edita.", "Datele furnizate sunt incomplete."); }
           
        }
```
  

  

FORM 2.  

  

Copy Code

```
string[] IDProdusContractPrelugit;
        string[] IDProdusContractRetras;

        public frmModificaContract(string[] IDProdusContractPrelugit, string[] IDProdusContractRetras)
        {
            InitializeComponent();
            this.IDProdusContractPrelugit = IDProdusContractPrelugit;
            this.IDProdusContractRetras = IDProdusContractRetras;
            AfisareProduseContract();
        }


        void AfisareProduseContract()
        {

            foreach (string ContractPrelungit in IDProdusContractPrelugit)
            {
                if (ContractPrelungit != null)
                {
                    Program.Connection.CommandText = "select * from ContractItems WHERE ContractItemId=@ContractItemId";
                    Program.Connection.AddParameter("@ContractItemId", ContractPrelungit);

                    DataTable Table = new DataTable();
                    Program.Connection.FillDataTable(Table, true);


                    for (int i = 0; i < Table.Rows.Count; i++)
                    {
                        if (String.IsNullOrWhiteSpace(Table.Rows[i]["DeletedId"].ToString()))
                        {
                            bool validare;
                            validare = true;

                            dataProduseContract.Rows.Add(validare, Table.Rows[i]["Name"].ToString(), Table.Rows[i]["Quantity"].ToString() + " " + Table.Rows[i]["QuantityUnit"].ToString(), Table.Rows[i]["Payment"].ToString(), Table.Rows[i]["Description"].ToString(), Table.Rows[i]["ContractItemId"].ToString());
                        }
                        else
                        {
                            bool validarescos;
                            validarescos = false;
                            dataProduseContract.Rows.Add(validarescos, Table.Rows[i]["Name"].ToString(), Table.Rows[i]["Quantity"].ToString() + " " + Table.Rows[i]["QuantityUnit"].ToString(), Table.Rows[i]["Payment"].ToString(), Table.Rows[i]["Description"].ToString(), Table.Rows[i]["ContractItemId"].ToString());
                            dataProduseContract.Enabled = false;
                        }

                    }
                }
            }

            
        }
```
  

  

The problem is allwais i have Null value in array.