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
Karthik jKarthik j 

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

Hii 
I am trying to deploy my code from git to sandbox, In the middle of this process I am getting this error.
OLHandler_test  afterInsert  System.NullPointerException: Attempt to de-reference a null object  External entry point.

Can anyone please help in solving this?
PriyaPriya (Salesforce Developers) 

Hi Karthik,


System.NullPointerException: Attempt to de-reference a null object is very common error in apex class.  It occurs when your variable (sobject, list, set or any other data type) is not initialized (allocated memory). In order to use the non primitive data type in the code we need to initialize the memory first. If we don’t do that it may result in Attempt to de-reference a null object error. This error may occur in Apex classes, Visualforce pages with Apex controller, Test classes, Apex Triggers.

For more information and their resolution, please refer the below link :- 

https://www.sfdcpoint.com/salesforce/system-nullpointerexception-attempt-to-de-reference-a-null-object/

 

https://developer.salesforce.com/forums/?id=906F00000008xK8IAI

 

Please mark it as best answer so that it can help others as well.

Regards,

Priya Ranjan

mukesh guptamukesh gupta
Hi Kartik

Can you please share the the code of OLHandler_test   with line number when you are gettign error due to deploymwnt

Regards
Mukesh

 
Ashish Singh SFDCAshish Singh SFDC
Hi Karthik,

As explained by @Priya you should be able to find the Null Pointer Exception. As mentioned by @Mukesh, if you still need help in identifying the error, you will have to share your code snippet with explanation and don't forgot to highlight the line Number and the error where this Exception is occuring.

Thanks,
Ashish Singh.