JIRA Directory synchronisation fails due to invalid XML character
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
Issue
Your Bitbucket Server is configured to use JIRA as a User Directory but suddenly stopped working. In the logs you can find an error like that:
ERROR [Caesium-1-4] c.a.c.d.DbCachingDirectoryPoller Error occurred while refreshing the cache for directory [ 123456 ].
com.atlassian.crowd.exception.OperationFailedException: javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1432; An invalid XML character (Unicode: 0x1a) was found in the value of attribute "name" and element is "user".]
Solution
There are two ways of determining which name causes the issue:
Option 1:
- Query the cwd_user table for any data containing character put in brackets. In our example, it's (Unicode: 0x1a).
The query depends on the database type, as the Unicode character might be represented differently in different databases.
If you wish to follow this path, please build a SELECT statement querying the JIRA CWD_USER table for the Unicode character mentioned in the log.
Option 2:
Save the output of:
SELECT * FROM CWD_USER;
to cwd_user.txt file
and search for the invalid characters manually:
grep --color='auto' --line-number --perl-regexp "[^\x00-\x7F]" cwd_user.txt
Once you find the faulty credentials, please correct them in JIRA (manually removing it and adding again should be enough), and start the synchronization again.