NullPointerException in JIRA Agile due to Corrupt JIRA Components
症状
When using JIRA Agile in JIRA 4.0.0, errors like the following are displayed on screen and/or in the logs:
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getDisplayValue' in class com.pyxis.greenhopper.jira.fields.Component threw exception class java.lang.NullPointerException : null at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:249) at
An error occurred whilst rendering this message. Please contact the administrators, and inform them of this bug. Details: ------- org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getTooltipValue' in class com.pyxis.greenhopper.jira.fields.Component threw exception class java.lang.NullPointerException : null at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:249) at
原因
Moving issues with subtasks between projects can result in corrupt component data in JIRA 3.13.5 and below, as described here: JRA-17312
This problem has been resolved in JIRA 4.0.0, but you may still have corrupt data from an earlier version.
ソリューション
Locate the problem records and clear out the bogus component data as follows:
Run a query like the following to find the list of issues whose components are from a different project:
select jiraissue.pkey from nodeassociation, jiraissue, component where nodeassociation.sink_node_entity='Component' and jiraissue.id = nodeassociation.source_node_id and component.id = nodeassociation.sink_node_id and component.project != jiraissue.project;
- If you have a small number of issues, you can simply edit each of the issues through the web interface and associate the issue with a valid component or clear out the component data.
Fixing a Large Number of Issues
If you have a large number of issues, you can remove the corrupt component data from the affected issues. As with any direct database update, this approach should be tested ahead of time.
- データベースをバックアップします。
Run the following query to flag the affected data:
create table tempAssociation as select * from nodeassociation na where na.sink_node_entity='Component' and (na.source_node_id, na.sink_node_id) in (select na2.source_node_id, na2.sink_node_id from nodeassociation na2, jiraissue ji, component c where na2.sink_node_entity='Component' and ji.id = na2.source_node_id and c.id = na2.sink_node_id and c.project != ji.project and na2.source_node_id = na.source_node_id and na2.sink_node_id = na.sink_node_id );
Run the following query to remove the affected data:
delete from nodeassociation where (source_node_id, sink_node_id) in (select source_node_id, sink_node_id from tempAssociation );
Remove the temporary table created during this process:
drop table tempAssociation;