Hi Team,
I'm creating an AEM user programmatically (i.e.) I'm creating the folder structure which looks exactly same as the package structure when we create a list of users (located under "/home/users") package using http://localhost:4502/crx/packmgr/index.jsp by selecting "/home/users" as filters. I tried to remove "jcr:uuid" property as it will be automatically created by AEM and tried to install the package but the package was not installed and got the below exception.
Could not Install Package
"org.apache.jackrabbit.vault.packaging.PackageException: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0021: Invalid jcr:uuid for authorizable username@domain.com"
Caused by: org.apache.jackrabbit.vault.packaging.PackageException: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0021: Invalid jcr:uuid for authorizable username@domain.com
Caused by: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0021: Invalid jcr:uuid for authorizable
username@domain.com
So, I have generated a random uuid using java.util.UUID.randomUUID().toString() and set it to the jcr:uuid property. When I tried to install the package, I got the below exception -
Error: org.apache.jackrabbit.vault.packaging.PackageException: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0021:
Invalid jcr:uuid for authorizable username@domain.com
Please help in this. May I know how exactly AEM is generating jcr:uuid value to a particular user? So that I can try the same approach, hope the above issue will be resolved.
Thanks,
Dinakar.
Solved! Go to Solution.
Views
Replies
Total Likes
This error usually happens when either the key or value of jcr:uuid is invalid
Looking into UserValidator class in source code
Line 76-79 generates this error, it calls isValidUUID method which is defined on lines 175-178
somewhere id is null or did not generate in valid format.
Views
Replies
Total Likes
This error usually happens when either the key or value of jcr:uuid is invalid
Looking into UserValidator class in source code
Line 76-79 generates this error, it calls isValidUUID method which is defined on lines 175-178
somewhere id is null or did not generate in valid format.
Views
Replies
Total Likes
There is another user who tried to create group programmatically recently faced same issue. Please review following post
Views
Replies
Total Likes
Hi Ahmed,
Thanks for the source code. I will go.through it and let u know. Currently I'm not setting any null value to jcr:uuid. I will check in which way AEM is taking it as valid or invalid.
Thanks,
Dinakar
Views
Replies
Total Likes
Hi Ahmed,
Thanks for the reply. I have seen that post. Unfortunately, the suggested approach is not suitable for my requirement. I'm not using any "org.apache.jackrabbit.api.
Your comments are welcome.
Thanks,
Dinakar
Views
Replies
Total Likes
Hi,
I have gone through different APIs. At last found how AEM is generating UUID (i.e.) the value of "jcr:uuid" property. Here it is -
Class: org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager
@Nonnull
public static String generateUUID(String hint) {
UUID uuid = UUID.nameUUIDFromBytes(hint.getBytes(Charsets.UTF_8));
return uuid.toString();
}
Pass the user name in lower case as parameter to this method (generateUUID(emailId.toLowerCase())) then we will get the correct UUID for the user. Based on the user name it will generate UUID.
My problem got resolved, I'm, able to install the package successfully.
Thanks,
Dinakar.
Views
Replies
Total Likes