function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

System Nullpointer Exception



I have a weird System Null Pointer exception! The system tells me:

System.NullPointerException: Attempt to de-reference a null object

Fehler in Ausdruck '{!BarVerkaufLieferungen_speichern}' in Komponente <apex:pageMessages> in page barverkauflieferungenzuordnen

Class.BarVerkaufWizardController.BarVerkaufLieferungen_speichern: line 4410, column 1


The code in this part of the code is:

                system.debug('############################# hier kümmern wir uns um die Rechnung alleRP ' + ReposList);
                if (RePosList != null){
                if ( RePosList.size() != 0){           <----- line 4410


How can the programm go to line 4410 if ReposList is null? Can anyone explain?





try this RePosList.size() > 0


it appears from your error that the addError message you are using is causing the issue. If you have not instantiated the ReposList yet it should not get to the line you have shown. I suspect there is something more going on.

Chamil MadusankaChamil Madusanka

Initialize your RePosList in constructor or before use that list.


RePosList = new List<YOUROBJECTTYPE>();


If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.


Hello Starz26,


thanks for you comment! in this context I'm not using the addError. As you said, if ReposList is null the program should not go to line 4410, but instead of this to the next statement after this if statement. What might be going on? In another environment with a total different Program I have a very similar error. I test there a variable, which is referring to the system debug not null, but then in the next statement, I get the System Null Pointer Exception. Perhaps it is helpful for you to know, that both methods are controller extensions and bot variables are public lists.


Do you have any ideas or hints, that may help?