XML backup import fails with GenericEntityException in Jira Data Center

Still need help?

The Atlassian Community is here for you.

Ask the community

Problem

When importing a JIRA XML backup to a JIRA instance with PostgreSQL in the backend, a GenericEntityException is thrown.  This is caused by the following SQL exception:

Error importing data: java.lang.Exception: com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:Action][id,31274][body...
...
SQL Exception while executing the following:INSERT INTO public.jiraaction (ID, issueid, AUTHOR, actiontype, actionlevel, rolelevel, actionbody, CREATED, UPDATEAUTHOR, UPDATED, actionnum) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (ERROR: invalid byte sequence for encoding "UTF8": 0x00)

Cause

The import process to PostgreSQL is trying to interpret plain-text comments as UTF-8 characters and will end up with the above errors because of the NULL values in the data.

If you are importing the backup from or to a different database, please refer to Switching databases.

Resolution

The best way to confirm this is to unzip the JIRA XML backup and examine the entities.xml file by one of two ways:

  • Using vim:
    1. vim -b entities.xml
    2. type :sy off to turn off colouring of output.
    3. type /^Vx00 to search for the NULL character.
      ^V means Control + V, which tells vim you're about to type something you want it to interpret literally. x00 is the character sequence for the NULL character.
  • The other way you can find the NULL is with grep
grep -nE '\x00' entities.xml | cat -v

Once you find and confirm there are NULLl values in the *entities.xml* file you can run the below command to fix it:

perl -pi -e 's/\x00//g' entities.xml

This strips the NULL character from the data. Once the file is fixed, re-archive it to it's original zip file and import it into JIRA which should work fine.

Resolution 2

After unzip the JIRA XML backup, you can use the Atlassian XML Cleaner

  1. Download atlassian-xml-cleaner-0.1.jar from this document.
  2. Open a command prompt and locate the XML or ZIP backup file on your computer, ensuring that it is extracted if it's within a ZIP file. In this example, we will use entities.xml.
  3. Run the application with the below:

    $ java -jar atlassian-xml-cleaner-0.1.jar entities.xml > entities-clean.xml

    This will create a copy of entities.xml as entities-clean.xml with the invalid characters removed. 

  4. Copy the entities-clean.xml and activeobjects.xml files into another directory, rename it back to entities.xml and create a new ZIP file to be imported.
  5. Import the new ZIP file, ensuring that it contains both XML files.

Last modified on Mar 26, 2024

Was this helpful?

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