Project import fails with too many errors in Jira server
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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
Problem
While importing a project from a Jira backup the import fails with the following error:
"The import was aborted because there were too many errors. Some errors are listed below. For full details about the errors please see your logs. Please note that some elements have been created. You may want to consult your logs to see what caused the errors, delete the project, and perform the import again."
The following appears in the atlassian-jira.log
2015-01-17 15:01:50,542 ProjectImport: CreateIssueRelatedData-10 ERROR admin 901x156x1 4bmvmr 127.0.0.1 /secure/admin/ProjectImportSummary.jspa [jira.imports.project.DefaultProjectImportPersister] DataAccessException occured while trying to create Entity type 'EntityProperty' . {id=10031, entityName=IssueProperty, entityId=10115, propertyKey=request.channel.type, value="Portal", created=2015-01-08 18:51:44.178, updated=2015-01-08 18:51:44.178}
com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:EntityProperty][id,10031][created,2015-01-08 18:51:44.178][updated,2015-01-08 18:51:44.178][entityId,10115][value,"Portal"][propertyKey,request.channel.type][entityName,IssueProperty] (SQL Exception while executing the following:INSERT INTO public.entity_property (ID, ENTITY_NAME, ENTITY_ID, PROPERTY_KEY, CREATED, UPDATED, json_value) VALUES (?, ?, ?, ?, ?, ?, ?) (ERROR: duplicate key value violates unique constraint "pk_entity_property"
Detail: Key (id)=(10031) already exists.))
at com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:397)
at com.atlassian.jira.ofbiz.WrappingOfBizDelegator.createValue(WrappingOfBizDelegator.java:219)
at com.atlassian.jira.imports.project.DefaultProjectImportPersister.createEntity(DefaultProjectImportPersister.java:192)
at com.atlassian.jira.imports.project.handler.EntityPropertiesPersisterHandler$1.run(EntityPropertiesPersisterHandler.java:63)
at com.atlassian.jira.util.concurrent.BoundedExecutor$1.run(BoundedExecutor.java:50)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
Caused by: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:EntityProperty][id,10031][created,2015-01-08 18:51:44.178][updated,2015-01-08 18:51:44.178][entityId,10115][value,"Portal"][propertyKey,request.channel.type][entityName,IssueProperty] (SQL Exception while executing the following:INSERT INTO public.entity_property (ID, ENTITY_NAME, ENTITY_ID, PROPERTY_KEY, CREATED, UPDATED, json_value) VALUES (?, ?, ?, ?, ?, ?, ?) (ERROR: duplicate key value violates unique constraint "pk_entity_property"
Detail: Key (id)=(10031) already exists.))
at org.ofbiz.core.entity.GenericDAO.singleInsert(GenericDAO.java:200)
at org.ofbiz.core.entity.GenericDAO.insert(GenericDAO.java:165)
at org.ofbiz.core.entity.GenericHelperDAO.create(GenericHelperDAO.java:83)
at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:554)
at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:540)
at org.ofbiz.core.entity.GenericValue.create(GenericValue.java:98)
at com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:392)
... 7 more
Cause
This happens due to an existing bug in Jira, reported on JRASERVER-41681 - Project import aborted due to too many errors (fixed in 6.4.14, 7.1.7and later)
Workaround
Please follow the step by step below:
- Categorize your instance:
- Source JIRA instance (the instance where the project import was generated from)
- Target JIRA instance ( the instance where you want to import your project into)
Run the SQL query below in the Target JIRA instance's database:
select max(id) from entity_property;
You will get a single value. Keep that value as you'll need to use it in the next steps.
- Unzip the backup from the Source JIRA instance. This will unzip two files:
entities.xml
andactiveobjects.xml
. - Download this file to the same folder where the
entities.xml
file is: fix_entity_ids.py Run the following in the terminal/cmd, replacing XXXXX with the value returned on step #2.
This requires Python 2.7.x. It will not work with Python 3+.
python fix_entity_ids.py XXXXX
If the Python script throws an error:
Could not find the 'entities.xml' file inside this folder
Please clean the
entities.xml
file as per Removing invalid characters from XML backups and then rerun the script. You will need to rename theentities-clean.xml
toentities.xml
after cleaning the XML file.If dealing with a really large entities.xml file (i.e. 50G) and the Python script cannot complete due to memory issues, download this file and run the following in the terminal/cmd, replacing XXXXX with the value returned on step #2. Once complete, there will be a new file named entities_output.xml that will have the updated entity property ids. Once complete, rename entities_output.xml to entities.xml:
java -jar entity-property-fixer-1.0.jar XXXXX
- Once completed, use the
output.xml
file that was generated from above python command, to import the project. Simply place this output.xml file to theimport
folder of the JIRA Home Directory and retry the Project Import as detailed in Restoring a Project from Backup.- For JIRA 7.x, please rename the
output.xml
file toentities.xml
and zip up withactiveobjects.xml
to do the Project Import.
- For JIRA 7.x, please rename the
After finishing the import,shut down the target instance
Reset the sequence_value_item table for EntityProperty types in the Target JIRA instance's database::
UPDATE sequence_value_item SET seq_id = (SELECT MAX(id)+100 FROM entity_property) WHERE seq_name = 'EntityProperty';
Restart the target instance