PCJ-Troubleshooting a NullPointerException caused due to a null text value for a custom field value

Problem Statement

When importing a project, the import process fails with an error similar to the below message related to a null text value for a custom field value.

Error Message 

Data import failed with exception: null java.lang.NullPointerException at com.awnaba.projectconfigurator.transporter.engine.JiraDataImporter.getProcessedCustomFieldMessageSet(JiraDataImporter.java:382) at com.awnaba.projectconfigurator.transporter.engine.JiraDataImporter.addMessagesFromMappingResult(JiraDataImporter.java:352) at com.awnaba.projectconfigurator.transporter.engine.JiraDataImporter.jiraImportData(JiraDataImporter.java:299) at com.awnaba.projectconfigurator.transporter.engine.JiraDataImporter.importData(JiraDataImporter.java:163) at com.awnaba.projectconfigurator.transporter.engine.JiraDataImporter$DataImportCallable.call(JiraDataImporter.java:456)

Log Entries 

There was an unexpected problem processing the file '/data/jira-install/temp/JiraProjectImportPYX1645549824833/CustomFieldValue.xml' when performing a project import. java.lang.NullPointerException at com.atlassian.jira.imports.project.customfield.TextLengthValidatingCustomFieldImporter.canMapImportValue(TextLengthValidatingCustomFieldImporter.java:24) at com.atlassian.jira.imports.project.handler.CustomFieldValueValidatorHandler.validateCustomFieldValueWithField(CustomFieldValueValidatorHandler.java:98) at com.atlassian.jira.imports.project.handler.CustomFieldValueValidatorHandler.handleEntity(CustomFieldValueValidatorHandler.java:73) at com.atlassian.jira.imports.project.handler.ChainedOfBizSaxHandler.endTopLevelElement(ChainedOfBizSaxHandler.java:221) at com.atlassian.jira.imports.project.handler.ChainedOfBizSaxHandler.endElement(ChainedOfBizSaxHandler.java:169)


Cause

If there is a null text value for a custom field value that is not expected to be null, the import fails when the Project Configurator tries to get the length of that value.

Solution

  1. In order to check the custom fields with null values, first run the below SQL script in the source database and check the result for any rows with NULL values in the custom field table.

Select * from customfieldvalue where STRINGVALUE is null and NUMBERVALUE is null and TEXTVALUE is null and DATEVALUE is null and VALUETYPE is null

Example Result :

2. If you found any Customfied IDs returning with Null values, you need to delete them from the customfield table in the source database by using the below SQL query:

Note : Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

3. After deleting, please perform a project re-index in the source instance and then do fresh export and import.

Â