After completing a patch upgrade of Semarchy xDM, administrators may encounter a NullPointerException: Null code error when attempting a model deployment operation. The error is most likely to occur in environments where an admin has configured database views, a new feature introduced in version 5.3 of the Semarchy xDM platform. Reference our official documentation for more info on configuring database views.

Below is an excerpt of the stack trace for this specific error.

java.lang.NullPointerException: Null code
  at com.semarchy.mdm.runtime.model.dbschema.impl.AutoValue_DBView.<init>(AutoValue_DBView.java:23)
  at com.semarchy.mdm.runtime.model.dbschema.impl.DBView.create(DBView.java:12)
  at com.semarchy.mdm.runtime.model.dbschema.impl.DBSchema.addView(DBSchema.java:131)
  at com.semarchy.mdm.runtime.model.dbschema.reveng.PostgreSQLSchemaReveng.reverseViews(PostgreSQLSchemaReveng.java:273)
  at com.semarchy.mdm.runtime.model.dbschema.reveng.PostgreSQLSchemaReveng.reverseSchema(PostgreSQLSchemaReveng.java:80)
  at com.semarchy.mdm.runtime.model.dbschema.reveng.SchemaRevengFactory.reverseSchema(SchemaRevengFactory.java:43)
  at com.semarchy.mdm.runtime.model.dbschema.reveng.SchemaRevengFactory.reverseSchema(SchemaRevengFactory.java:47)
  at com.semarchy.mdm.datahub.admin.impl.DataLocationSchemaSupport.getSchemaDiffForUpdate(DataLocationSchemaSupport.java:109)
  at com.semarchy.mdm.datahub.admin.impl.DefaultDataLocationAdminService.getSchemaDiffForUpdate(DefaultDataLocationAdminService.java:473)
  at com.semarchy.ui.platform.admin.wizards.ShowDDLPage$3.run(ShowDDLPage.java:124)
  at org.eclipse.jface.operation.ModalContext$ModalContextThread$1.run(ModalContext.java:127)
  at org.eclipse.rap.rwt.internal.lifecycle.ContextUtil.runNonUIThreadWithFakeContext(ContextUtil.java:67)
  at org.eclipse.rap.rwt.internal.service.UISessionImpl.exec(UISessionImpl.java:251)
  at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

Root Cause Analysis

  1. From the stack trace, we can interpret that the schema reverse is failing while reversing a database view.
  2. From the stack trace, we can interpret that the information_schema.views.view_definition column is null for one of the database views of the data location schema.
  3. From the stack trace, we can interpret that a condition may exist in which the executing user may lack the necessary permissions to see the definition of a view, thereby emulating a null view_definition.
  4. In summary, we can conclude once the view with a null view_definition is identified that:
  • removing the view temporarily will bypass the error.
  • granting the executing user owner permissions on the view will resolve the error.

Resolution

1. Run the following SQL query to identify view(s) which match the criteria (missing/blank view_definition column); do not forget to replace %CURRENT_SCHEMA% with the name of the current data location schema.

select v.table_name, v.view_definition, d.description 
 from information_schema."views" v
 inner join pg_catalog.pg_class c
 on v.table_schema = %CURRENT_SCHEMA%
 and c.oid = v.table_name::regclass::oid
 left join pg_catalog.pg_description d
 on d.objoid = v.table_name::regclass::oid

2. Change the owner of the view with one of the following methods:

  • Grant the data location user owner permissions

OR

  • Drop the view in the schema and recreate it by re-deploying the model.

References

Semarchy Release Notes - Understanding Database Views

Semarchy Integration Guide - Configuring Database Views