Resource Table Generation returns error 'Cannot invoke' because "unit" is null

While running data administration on DHIS2 v2.41, I encountered the following error.

Hi @SanghArsha_PyakuRel

Is this the first time you run the Resource Tables generation in your instance or were there previously successful runs. Could there have been any changes to the system that are causing this?

Looking at the first error which has to do with the Organisation unit structure (the first table that’s being generated), did you make any changes to the OUs? Would it be possible to first use the Data Administration → Maintenance → Update organisation unit paths, Clear application cache, and Reload apps … then try again.

Additionally, if possible please check your Catalina.out log to see if there are helpful error logs.

Thanks!