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
rajjjjrajjjj 

Error while running a batch class through developer console

When i am running a batch class using developer console i am getting this NullPointerException

I dont know why????

I have read in boards that if we are trying to access a field value which is null then we may get that error.

 

METHOD_ENTRY|TestClass.createPortalUser(Contact)
EXCEPTION_THROWN| |System.NullPointerException: Attempt to de-reference a null object
METHOD_EXIT|[131]|TestClass.createPortalUser(Contact)
FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

 

what is the best way to get out of this error???

Starz26Starz26

It all depends on what you are trying to do.....

 

A bit of code from your class and a use case will help...

T-007T-007

Its not about where you running the batch class,  this is the common error when we don't have any records. write your use case here , that gives best solution for ur problem

rajjjjrajjjj

I am trying to insert user records and copy them on a seperate custom object in an after trigger.

There was a batch class written to create user records. As soon as the user records are created i need to copy them in custom object.

In that process when i am running the batch job through developer console i am getting the error in Apex Jobs.

 

T-007T-007

paste ur code here. it will help us to identify the error. few days before i did this same stuff, but  not in developer console

Anup JadhavAnup Jadhav

Null pointer excpetion usually means you haven't instantiated the sObject or variable that you're trying to use. Sometimes it could be 2 or 3 levels deep if you are referencing objects via relationships (like parent__c.child__c.name etc).

 

Unless you paste a sample code, or paste the error log we won't be able to figure out what's wrong with your code.

 

- Anup

rajjjjrajjjj

I haven't given the first nameand i was using that in batch class....so i was facing that issue.....de-reference to null object.

I solved that.

Sorry that is a 600 line code...it cant be pasted here.....:)

 

One more issue was i wrote a trigger which inserts new records on a custom object.

I wrote an after trigger on User and in that trigger i was trying to insert non-setup object ( to be clear custom object )records. So i was getting Mixed DML operation exception.

For that i have used @future annotation...I thought that resolved my issue.But i had a batch class which creates portal users and that batch class is calling this future method. So i am again getting an exception that "Future methods cannot call another batch or future methods".

 

Is there any way to get rid of that issue?????