Problems in generating UUID using com.day.util.UUID | Community
Skip to main content
Dinu_Arya
Level 6
October 16, 2015
Solved

Problems in generating UUID using com.day.util.UUID

Hi Team,

I'm trying to generate UUID using com.day.util.UUID.create() and using constructor also.

I'm getting the below exception while generating through constructor -

Exception in thread "main" java.lang.InternalError: MD5 not available
    at com.day.util.UUID.<init>(UUID.java:147)

I'm getting the below exception while generating through create() method-

Exception in thread "main" java.lang.NullPointerException
    at com.day.util.UUID.<init>(UUID.java:190)
    at com.day.util.UUID.create(UUID.java:328)

Do I need to set up anything before generating UUID using com.day.util.UUID api? I'm using "day-commons-misc-1.1.2.jar". Because, the below maven dependencies are not working for me -

    <dependency>
            <groupId>com.day.commons</groupId>
            <artifactId>day-commons-misc</artifactId>
            <version>1.1.2</version>
            <scope>provided</scope>
    </dependency>

Any idea?

Please let me know.

Thanks,

AryA.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Dinu_Arya
Dinu_AryaAccepted solution
Level 6
October 16, 2015

Hi Scott,

Observed that AEM is creating the UUID like below and the below one worked for me -

UUID.nameUUIDFromBytes(<emailID>.getBytes(Charsets.UTF_8)).toString()

This method is located in org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager

Now I'm able to install the package successfully.

Thanks,

AryA.

3 replies

smacdonald2008
Level 10
October 16, 2015

To create a globally unique ID from within an OSGi class - use this java:

UUID class. UUID uuid = UUID.randomUUID();     

String randomUUIDString = uuid.toString(); 

Translate
Dinu_Arya
Dinu_AryaAuthor
Level 6
October 16, 2015

Hi Scott,

Thanks, May I know the reason why you are suggesting java.util.UUID api? Actually I tried with UUID.randomUUID().toStrong() in order to set it to "jcr:uuid" property of an AEM user programmatically. But I'm getting the below exception while installing the package through http://localhost:4502/crx/packmgr/index.jsp -

com.day.jcr.vault.packaging.PackageException: org.apache.jackrabbit.vault.packaging.PackageException: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0021: Invalid jcr:uuid for authorizable myname@domain.com

Here I'm trying to create an AEM user myname@domain.com. For this I have created the structure ("/home/users/myname@domain.com") programmatically under jcr_root folder. Also META-INF folder. But while installing the package, I got the above exception. That is showing error in jcr:uuid. So I thought of using AEM related UUID API.

But I'm running through the errors.

How exactly, AEM is generating "jcr:uuid" value for an user? I think I have to follow the way exactly how AEM generates "jcr:uuid" or Am I doing anything wrong? I have written proper filter.xml as well. Please let me know.

Thanks,

AryA.

Translate
Dinu_Arya
Dinu_AryaAuthorAccepted solution
Level 6
October 16, 2015

Hi Scott,

Observed that AEM is creating the UUID like below and the below one worked for me -

UUID.nameUUIDFromBytes(<emailID>.getBytes(Charsets.UTF_8)).toString()

This method is located in org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager

Now I'm able to install the package successfully.

Thanks,

AryA.

Translate