Project import fails with NumberFormatException in Jira Server/Data Center
Problem
When importing a Jira Software project, the import fails and the following error is displayed in the logs (atlassian-jira.log):
2016-04-01 01:47:03,483 JiraTaskExectionThread-6 ERROR username 103x3090x1 13tcomw 195.xxx.xxx.xxx,127.0.0.1 /secure/admin/ProjectImportSummary.jspa [c.a.j.imports.xml.DefaultBackupXmlParser] Unexpected import failure
java.lang.NumberFormatException: null
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.valueOf(Unknown Source)
at com.atlassian.greenhopper.imports.SprintImportHandler.endTable(SprintImportHandler.java:105)
at com.atlassian.jira.imports.project.ao.handler.ChainedAoSaxHandler.endTable(ChainedAoSaxHandler.java:260)
at com.atlassian.jira.imports.project.ao.handler.ChainedAoSaxHandler.endElement(ChainedAoSaxHandler.java:187)
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.importAoData(DefaultProjectImportManager.java:708)
at com.atlassian.jira.imports.project.DefaultProjectImportManager.doImport(DefaultProjectImportManager.java:656)
at com.atlassian.jira.bc.imports.project.DefaultProjectImportService.doImport(DefaultProjectImportService.java:416)
at com.atlassian.jira.web.action.admin.importer.project.ProjectImportSummary$ProjectImportCallable.call(ProjectImportSummary.java:285)
at com.atlassian.jira.web.action.admin.importer.project.ProjectImportSummary$ProjectImportCallable.call(ProjectImportSummary.java:236)
at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:453)
(...)
Cause
There are issues in the imported project which are included in Sprints that do not exist in the database anymore (in the AO_60DB71_SPRINT table).
- JSWSERVER-16064Getting issue details... STATUS
Investigation
Run the following query in the source instance's database (the Jira Software instance where the XML Backup was taken) to find the affected entries:
The queries below were tested for PostgreSQL and MySQL, you would need to find the corresponding query for your database type
-- List all references to the nonexistent Sprints
SELECT * FROM customfieldvalue
WHERE customfield = (SELECT ID FROM customfield WHERE customfieldtypekey LIKE '%com.pyxis.greenhopper.jira:gh-sprint%')
AND CAST(stringvalue as int) NOT IN (SELECT "ID" FROM "AO_60DB71_SPRINT");
-- List all references to the nonexistent Sprints
SELECT * FROM customfieldvalue
WHERE customfield = (SELECT ID FROM customfield WHERE customfieldtypekey LIKE '%com.pyxis.greenhopper.jira:gh-sprint%')
AND stringvalue NOT IN (SELECT ID FROM AO_60DB71_SPRINT);
Resolution
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.
- Stop your Jira Software source instance.
Run the SQL query below in the database to delete the invalid Sprint references:
Query 3 (PostgreSQL)DELETE FROM customfieldvalue WHERE customfield = (SELECT ID FROM customfield WHERE customfieldtypekey LIKE '%com.pyxis.greenhopper.jira:gh-sprint%') AND CAST(stringvalue AS int) NOT IN (SELECT "ID" FROM "AO_60DB71_SPRINT");
Query 3 (MySQL)DELETE FROM customfieldvalue WHERE customfield = (SELECT ID FROM customfield WHERE customfieldtypekey LIKE '%com.pyxis.greenhopper.jira:gh-sprint%') AND stringvalue NOT IN (SELECT ID FROM AO_60DB71_SPRINT);
- Start your Jira Software source instance.
- Generate a new XML Backup from the source instance and perform the Project Import in the target instance again.