Java: Importing node fails because child node with non-existent UUID not found

Hi,

I’m using the JCR Session interface to import a node into my repository. The node itself is saved as an XML file and I’ve written code that consumes the file and saves it to the repo.

public boolean importContent(InputStream inputStream, String path) throws JCRSessionException {
	
    try {
		
    session.getWorkspace()
                .importXML(path, inputStream, IMPORT_UUID_COLLISION_REPLACE_EXISTING);
            } catch (RepositoryException e) {
                throw new JCRSessionException(JCR_REPOSITORY_ERROR, e.getMessage());
            } catch (IOException e) {		
        return false;
    }
	
    return true;
}

The UUID of the node I’m importing is e33ea15d-1735-49ed-a2bc-3d18de04864d but when I try to import it fails because of a ConstraintViolationException saying “Could not find child 029d9c48-5825-4d49-bb4c-2ebb94f73df4 of node e33ea15d-1735-49ed-a2bc-3d18de04864d”.

I’ve checked the contents of the XML file and that child node UUID isn’t in there, so I’m not sure where it came from. The issue also only occurs when specify the condition IMPORT_UUID_COLLISION_REPLACE_EXISTING. If I create new UUIDs upon import, it works fine (albeit it creates a duplicate copy of the node). The XML file itself seems valid as I’ve tested importing it via the “XML Import” feature on the console and it imports successfully. Any help would be appreciated.

Thanks