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
songlansonglan 

batch in post install script cause a First error: Attempt to de-reference a null object error

Hello all,

 

I installed in my developer org a package with a batch in the post install script.  After installation, the batch is executed with Status Detail:First error: Attempt to de-reference a null object. But when I execute the batch manuelly (with execute anonymous) it works. I turned on the debug log before installation but don't see anything in the log and the Notify on Apex Error is set but no mail received. 

 

Anyone have some ideas of what happened or how I can get some log for the post install script?

 

Thanks in advance.

Best Answer chosen by Admin (Salesforce Developers) 
songlansonglan

I figured it out. In the post install script I called a method from a "with sharing" class, which the "post install script executor" doesn't have access I suppose. I removed the "with sharing" and it works.

All Answers

songlansonglan

I find this http://www.tgerm.com/2010/09/batch-apex-de-reference-null-object.html

But in my case, the query is Select Id From Account Where... and can't be null

Bhawani SharmaBhawani Sharma
Are you dependent on any org data?
songlansonglan

yes in the batch I read some contact and account fields and generate attachments.

songlansonglan

I figured it out. In the post install script I called a method from a "with sharing" class, which the "post install script executor" doesn't have access I suppose. I removed the "with sharing" and it works.

This was selected as the best answer