Updating a custom field context fails with HTTP 500 "java.lang.ArrayIndexOutOfBoundsException"
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
When updating the context of a custom field, saving the new configuration fails.
An HTTP 500 is shown in the UI with the text:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Sorry, we had some technical problems during your last operation.
Request assistance
Copy the content below and send it to your Jira Administrator
Technical details
Log's referral number: b81add7a-0746-4664-aea0-13f72328e507
Cause
Referer URL: https://jira.example.com/secure/admin/ManageConfigurationScheme!default.jspa?atl_token=BWJ2-FNVR-C0IJ-9MEY_4d88c472bd4189605a74f9053297fdbb2cc7bd5f_lin&fieldConfigSchemeId=20504&customFieldId=16302&returnUrl=ConfigureCustomField%21default.jspa%3FcustomFieldId%3D16302
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at com.atlassian.jira.web.action.admin.customfields.ManageConfigurationScheme.doExecute(ManageConfigurationScheme.java:185) [classes/:?]
Diagnosis
This error will occur if no issue types are selected for the field context, not even the Any issue type option.
Cause
When a change is done to a field context, the entries from the fieldconfigschemeissuetype and configurationcontext (among others) are deleted and re-added. In this scenario, the attempt to delete the entry from the fieldconfigschemeissuetype table fails with an NPE.
This can be validated if the SQL query below returns no rows:
1
SELECT * FROM fieldconfigschemeissuetype WHERE fieldconfigscheme = <fieldconfigscheme_id>;
ℹ️ Note that <fieldconfigscheme_id> in the query should have the value from the fieldConfigSchemeId parameter in the referer URL of the error above.
It's still not known why such a row would be absent from the table. This could happen if the re-insertion failed or the user interrupted the process after the deletion.
Solution
Solution 1:
Create a new context that's identical to the original context (the one that can't be saved) then delete the original.
This action does not cause any data loss in the custom field.
Solution 2:
In some scenario it may happen that no issueType is available for Global context and there is no option to delete the context. Users may also want to avoid deleting existing context. In these scenarios, below mentioned steps would be useful.
As per the document Manually inserting records, if user want to manually insert records into Jira database tables, user must update SEQUENCE\_VALUE\_ITEM manually. Set the relevant rows’ SEQ\_ID values to a value greater than the actual maximum ID in the table. To ensure all database caches are reset, need Jira restart.
User would have to insert the entry in the fieldconfigschemeissuetype table. This entry is the mapping of fieldConfigSchemeId with issueType id.
Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
select * from SEQUENCE_VALUE_ITEM where seq_name like '%FieldConfigSchemeIssueType%';
seq_name | seq_id
----------------------------+--------
FieldConfigSchemeIssueType | 27400
select id from fieldconfigscheme where fieldid = 'customfield_16302';
ID |
-----+
20504|
select id from fieldconfiguration where fieldid = 'customfield_16302';
ID |
-----+
20504|
select Max(id) from fieldconfigschemeissuetype;
MAX(ID)|
-------+
27352|
SELECT id FROM ISSUETYPE i WHERE PNAME = 'Test' ;
ID |
-----+
10300|
INSERT INTO fieldconfigschemeissuetype (id, issuetype, fieldconfigscheme, fieldconfiguration) VALUES(27353, 10300, 20504, 20504);
Restart of JIRA is required, so that changes are visible.
Was this helpful?