Project import fails with too many errors in Jira server

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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  JRA-41681 - Getting issue details... STATUS .

Workaround

Please follow the step by step below:
  1. Categorize your instance:
    1. Source JIRA instance (the instance where the project import was generated from)
    2. Target JIRA instance ( the instance where you want to import your project into)
  2. 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.

  3. Unzip the backup from the Source JIRA instance. This will unzip two files: entities.xml and activeobjects.xml.
  4. Download this file to the same folder where the entities.xml file is: fix_entity_ids.py
  5. 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

    (info) 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 the entities-clean.xml to entities.xml after cleaning the XML file.
    (info) 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
  6. 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 the import folder of the JIRA Home Directory and retry the Project Import as detailed in Restoring a Project from Backup.
    1. For JIRA 7.x, please rename the output.xml file to entities.xml and zip up with activeobjects.xml to do the Project Import.
  7. After finishing the import,shut down the target instance

  8. 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';
  9. Restart the target instance

Last modified on Sep 25, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.