When migrating users and groups from one AEM instance to another via Package Manager, the error below is shown:
26.01.2017 16:03:20.024 *ERROR* [qtp2078058939-7783] org.apache.jackrabbit.vault.fs.io.Importer Error while committing : javax.jcr.nodetype.ConstraintViolationException: OakConstraint0027: The admin user cannot be removed. javax.jcr.nodetype.ConstraintViolationException: OakConstraint0027: The admin user cannot be removed. Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: OakConstraint0027: The admin user cannot be removed
When packaging users and groups, you should make sure to avoid packaging out of the box users including the admin and anonymous users. In addition, you must use the merge package filter mode.
-
Click Execute and copy the path of the anonymous user node in the results to a text file (so now you should have two paths, one for "admin" and one for "anonymous")
For example:
/home/users/Q/QY5FIMXeQIbGpwZtQ3Dv – admin user on the system where I am creating the package
/home/users/K/Kj1406Qo9IDODc_nk5Ib – anonymous user on the system where I am creating the package
-
Add a filter to the package config for /home/users with these exclude rules (on the /home/users filter):
exclude /home/users/.*/.tokens
exclude /home/users/Q/QY5FIMXeQIbGpwZtQ3Dv
exclude /home/users/K/Kj1406Qo9IDODc_nk5Ib
exclude /home/users/a/admin
exclude /home/users/a/anonymous
exclude /home/users/system
exclude /home/users/geometrixx
exclude /home/users/media
exclude /home/users/projects
exclude /home/users/mac
-
<?xml version="1.0" encoding="UTF-8"?> <workspaceFilter version="1.0"> <filter root="/home/users" mode="merge"> <exclude pattern="/home/users/.*/.tokens"/> <exclude pattern="/home/users/Q/QY5FIMXeQIbGpwZtQ3Dv"/> <exclude pattern="/home/users/K/Kj1406Qo9IDODc_nk5Ib"/> <exclude pattern="/home/users/a/admin"/> <exclude pattern="/home/users/a/anonymous"/> <exclude pattern="/home/users/system"/> <exclude pattern="/home/users/geometrixx"/> <exclude pattern="/home/users/media"/> <exclude pattern="/home/users/projects"/> <exclude pattern="/home/users/mac"/> </filter> </workspaceFilter>
-
(Upgrade only): If performing migration to newer AEM version, then install a fresh local AEM instance (with nosamplecontent) and install the users package and the groups package there. Then perform an in-place upgrade on that instance. After upgrading, then repackage the users again, then the groups again and download the newer version of the packages.