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
Edmondo Porcu 2Edmondo Porcu 2 

NullPointerException in Apply Domain Layer Principles

I am trying to pass the "Apply Domain Layer Principles" assignment in Developer Advanced but I get stucked to the following issues:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AccountsTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Class.fflib_SObjectDomain.triggerHandler: line 345, column 1 Class.fflib_SObjectDomain.triggerHandler: line 321, column 1 Trigger.AccountsTrigger: line 5, column 1: []

The error occurs in line 345 of  Class.fflib_SObjectDomain.triggerHandler (the second one in the snippet)
Type constructableClass = domainClassName.endsWith('Constructor') ? Type.forName(domainClassName) : Type.forName(domainClassName+'.Constructor');
			IConstructable domainConstructor = (IConstructable) constructableClass.newInstance()
So it seems that Apex Commons can't retrieve by reflection the instance of the domain class (which is called Accounts). Has this something to do with the version of the API I am running?
 
Tim Chadwick 1Tim Chadwick 1
Have you added the below constructor 

     public class Constructor implements fflib_SObjectDomain.IConstructable {
        public fflib_SObjectDomain construct(List<SObject> sObjectList) {
            return new Accounts(sObjectList);
        }
    }