Summary:

An error message may be displayed when attempting to access an SDATA resource. The error message refers to a null pointer exception when calling the processCustomView method in CustomDataResource.


Symptoms:

The erorr message may appear when accessing the Sage CRM SDATA schema, or when attempting to access a specific resource. The following will be displayed:

java.lang.NullPointerException
 at com.sage.crm.sdata.classes.CustomDataResource.processCustomView(CustomDataResource.java:135)
 at com.sage.crm.sdata.classes.CustomDataResource.<init>(CustomDataResource.java:66)
 at com.sage.crm.sdata.endpoint.SDataSchemaEndpoint.processAllResources(SDataSchemaEndpoint.java:173)
 at com.sage.crm.sdata.endpoint.SDataSchemaEndpoint.handleMessage(SDataSchemaEndpoint.java:84)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 ...
 at com.sage.crm.web.filters.ClearCurrentThreadLocalsFilter.doFilter(ClearCurrentThreadLocalsFilter.java:45)
 ...
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)

Cause:

The issue is caused by a custom view that does not reference a valid Sage CRM entity. On accessing an SDATA resource, a lookup is made from the Custom_Views table against the referenced entities on the Custom_Tables table. This is done using a foreign key on the Custom_Views table (CuVi_CustomTableIDFK) which points to Bord_TableId on the Custom_Tables table.

Typically this error is encountered following an upgrade - the view's CuVi_CustomTableIDFK entry on the Custom_Views table will reference the _undefined placeholder entity. These views can be identified by running the following SQL:

select CuVi_ViewID, CuVi_ViewName, CuVi_Entity, CuVi_CustomTableIDFK
from Custom_Views
where CuVi_CustomTableIDFK not in (
    select Bord_TableId
    from Custom_Tables
    where bord_name not like '_undefined%')


Resolution:

A backup should be carried out before attempting the following:

  1. Delete the problem entry from the Custom_Views table.
  2. Drop the problem view from the database.
  3. Refresh the Sage CRM views metadata.