Project Import of Software project fails with Unexpected import failure
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
Problem
While performing a project import , the project import fails.
The following appears in the atlassian-jira.log
2016-01-28 21:17:46,155 JiraTaskExectionThread-3 DEBUG jira 1277x1055x1 1y08lty 127.0.0.1 /secure/admin/ProjectImportSelectProject.jspa [c.a.j.i.p.ao.handler.ChainedAoSaxHandler] Starting parsing Document with ChainedAoSaxHandler
2016-01-28 21:17:47,676 JiraTaskExectionThread-3 ERROR jira 1277x1055x1 1y08lty 127.0.0.1 /secure/admin/ProjectImportSelectProject.jspa [c.a.j.imports.xml.DefaultBackupXmlParser] Unexpected import failure
java.lang.NullPointerException
at com.atlassian.greenhopper.imports.LexorankPreImportHandler.addFieldMapping(LexorankPreImportHandler.java:94)
at com.atlassian.greenhopper.imports.LexorankPreImportHandler.handleEntity(LexorankPreImportHandler.java:78)
at com.atlassian.jira.imports.project.ao.handler.ChainedAoSaxHandler.endRow(ChainedAoSaxHandler.java:286)
at com.atlassian.jira.imports.project.ao.handler.ChainedAoSaxHandler.endElement(ChainedAoSaxHandler.java:190)
at com.atlassian.jira.imports.project.ao.handler.ChainedAoSaxHandler.endElement(ChainedAoSaxHandler.java:148)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.atlassian.security.xml.RestrictedXMLReader.parse(RestrictedXMLReader.java:103)
at com.atlassian.jira.imports.xml.DefaultBackupXmlParser$XmlParser.parseXml(DefaultBackupXmlParser.java:115)
at com.atlassian.jira.imports.xml.DefaultBackupXmlParser.parse(DefaultBackupXmlParser.java:64)
at com.atlassian.jira.imports.xml.DefaultBackupXmlParser.parseXml(DefaultBackupXmlParser.java:52)
at com.atlassian.jira.imports.xml.DefaultBackupXmlParser.parseAoBackupXml(DefaultBackupXmlParser.java:46)
at com.atlassian.jira.imports.project.DefaultProjectImportManager.getAoProjectImportData(DefaultProjectImportManager.java:358)
at com.atlassian.jira.imports.project.DefaultProjectImportManager.getProjectImportData(DefaultProjectImportManager.java:252)
at com.atlassian.jira.bc.imports.project.DefaultProjectImportService.getProjectImportData(DefaultProjectImportService.java:578)
at com.atlassian.jira.web.action.admin.importer.project.ProjectImportSelectProject$MappingResultCallable.call(ProjectImportSelectProject.java:252)
at com.atlassian.jira.web.action.admin.importer.project.ProjectImportSelectProject$MappingResultCallable.call(ProjectImportSelectProject.java:233)
at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:458)
at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:426)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.atlassian.jira.task.ForkedThreadExecutor$ForkedRunnableDecorator.run(ForkedThreadExecutor.java:216)
at java.lang.Thread.run(Thread.java:745)
2016-01-28 21:17:47,677 JiraTaskExectionThread-3 ERROR jira 1277x1055x1 1y08lty 127.0.0.1 /secure/admin/ProjectImportSelectProject.jspa [c.a.j.imports.project.DefaultProjectImportService] There was an unexpected problem processing the file '/opt/data/jira/import/jira-7.0.9.export.zip' when performing a project import.
Cause
The rank values in the database (exported to activeobjects.xml) refer to a non-existing LexoRank field which causes the project import to fail.
This could be caused by the bug below, after removing duplicated LexoRank fields:
Resolution 1
This is tested on PostgreSQL and may need modifying for other DBMS such as Oracle or SQL Server.
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.
- Run the following SQL against the source JIRA's database to remove any orphaned rank values:
DELETE FROM "AO_60DB71_LEXORANK"
WHERE "FIELD_ID" > 0
AND "FIELD_ID" NOT IN (SELECT id FROM customfield
WHERE customfieldtypekey = 'com.pyxis.greenhopper.jira:gh-lexo-rank');
- Lock and Reindex JIRA
- Generate a new XML backup and use that for the project import
Resolution 2
This is tested on PostgreSQL and may need modifying for other DBMS such as Oracle or SQL Server.
Warning
Please note that Resolution 2 option is only valid if you do not have Advanced Roadmaps for Jira installed. Advanced Roadmaps for Jira saves its ranking information in the AO_60DB71_LEXORANK with large negative FIELD_ID values between the range of -859340285902835 and -123340285902321.
Deleting rank entries related to Advanced Roadmaps for Jira can break Advanced Roadmaps for Jira and prevent creation of any new Portfolio plans.
- If Resolution 1 does not work, another possibility is that the AO_60DB71_LEXORANK table contains multiple entries pointing to invalid rank fields, with the FIELD_ID indicated being a large negative number.
You can find them by using this SQL query:
SELECT * FROM "AO_60DB71_LEXORANK" WHERE "FIELD_ID" < 0;
If the select statement returns more than a couple of rows and you do not have Advanced Roadmaps for Jira installed, do the following:
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.
It is important to do a backup of your database before the procedure as well as attempting a backup of the target instance before doing the System Restore
- Stop the source instance (where the XML Backup used for the project import was generated)
Clean up the Lexorank table by executing the following SQL command (Please notice - this step will delete all ranking data for all issues in JIRA):
DELETE FROM "AO_60DB71_LEXORANK";
Obtain the Rank FIELD ID(s) from your database by running the following SQL query:
SELECT * FROM customfield WHERE customfieldtypekey = 'com.pyxis.greenhopper.jira:gh-lexo-rank';
Insert the initial lexorank markers by running the following SQL queries. Notice the <Rank FIELD_ID> will need to be replaced with the actual rank field id from your database (step 3 above). If there's more than one rank field, the markers will need to be inserted for all the rank fields)
INSERT INTO "AO_60DB71_LEXORANK" ("ID", "FIELD_ID", "ISSUE_ID", "RANK", "TYPE") VALUES (DEFAULT, <Rank FIELD_ID>, -9223372036854775808, '0|000000:', 0); INSERT INTO "AO_60DB71_LEXORANK" ("ID", "FIELD_ID", "ISSUE_ID", "RANK", "TYPE") VALUES (DEFAULT, <Rank FIELD_ID>, 9223372036854775807, '0|zzzzzz:', 2);
- Start JIRA
- Run a full Reindex (JIRA Administration > System > Indexing), any of the available options will work.
- Generate a new XML backup
- Perform the Project Import in the target instance.