Creating new Jira issues throws java.lang.NullPointerException


If you get the java.lang.NullPointerException error page as above when you are trying to create a new issue, then most likely it has something to do with the Default Issue Type Scheme of your Jira. Follow the diagnoses steps in this knowledge base Jira server throws NullPointerException when creating new issues or changing project settings to find out why the Default Issue Type Scheme is not working properly.

In our case, the default issue type scheme get deleted via the add-on named Optimizer for Jira. Well, it was a human error but I think it is a serious bug in Optimizer for Jira. As in the native Jira UI, user don’t have the option to delete the default issue type scheme, but user can do it in Optimizer for Jira even without any warnings! So be careful if you are using it for cleaning up the issue type schemes.

The fix is not that hard if you have a recent database backup. This how I fixed ours:

  1. Restore the database (it is Oracle in our case) to a non-prod environment.
  2. Run the following query in the restored environment.
    select * from fieldconfiguration where id in (select id from fieldconfigscheme where configname=’Default Issue type Scheme’) and fieldid = ‘issuetype’;
  3. Let’s assume the id is 10000 from the above results. Then run the following query in the problematic environment. If it returns null then it confirms the default issue type scheme is missed.
    select * from fieldconfiguration where id=10000;
    select * from fieldconfigscheme where configname=’Default Issue Type Scheme’;
  4. Stop the problematic Jira then create a DB backup.
  5. Run the following four insert commands to re-create the Default Issue Type Scheme, and associate it with the un-configured projects.
    insert into fieldconfiguration values (10000,’Default Configuration for Issue Type’,’Default configuration generated by Jira’,’issuetype’,NULL);
    insert into fieldconfigscheme values (10000,’Default Issue Type Scheme’,’Used for all default’,’issuetype’,NULL);
    insert into configurationcontext values ((select max(id)+1 from configurationcontext),NULL,NULL,’issuetype’,(select id from fieldconfigscheme where configname=’Default Issue Type Scheme’));
    insert into fieldconfigschemeissuetype values (10100,null,(select id from fieldconfiguration where id in (select id from fieldconfigscheme where configname=’Default Issue Type Scheme’) and fieldid = ‘issuetype’),(select id from fieldconfiguration where id in (select id from fieldconfigscheme where configname=’Default Issue Type Scheme’) and fieldid = ‘issuetype’));
  6. Run the step 3 query again to ensure it has been re-created.
  7. By now, the Default Issue Type Scheme should be back in DB, but it has no any associated issue types. Go back to the step 1 restored database and run the following command to get the associations.
    select * from optionconfiguration oc join issuetype it on oc.optionid = it.id where oc.fieldconfig = ‘10000’;
  8. Now we need to populate the optionconfiguration table with the first five columns of the above results into the problematic environment. Here is an example.
    insert into optionconfiguration values (38486,’issuetype’,70,10000,62);
    insert into optionconfiguration values (38491,’issuetype’,10000,10000,67);
    insert into optionconfiguration values (38496,’issuetype’,10200,10000,72);
  9. Start Jira.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s