Issue while creating user with profile image | Community
Skip to main content
viveksachdeva
Community Advisor
Community Advisor
October 16, 2015
Solved

Issue while creating user with profile image

  • October 16, 2015
  • 2 replies
  • 1013 views

I am using AccountManager API to create users. It works just fine when I dont use profile image in registration form and user gets registered but when I use profile image, I get following error:

Caused by: javax.jcr.nodetype.ConstraintViolationException: No matching property definition: jcr:primaryType = sling:Folder
at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.setProperty(NodeDelegate.java:522)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1308)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1297)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:293)
at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:113)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1297)
at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:340)
at org.apache.sling.jcr.resource.JcrModifiablePropertyMap.save(JcrModifiablePropertyMap.java:180)
... 145 more
 
There is a hidden field to create this folder 
 <hidden
                jcr:primaryType="nt:unstructured"
                sling:resourceSuperType="foundation/components/form/defaults/field"
                sling:resourceType="foundation/components/form/hidden"
                defaultValue="sling:Folder"
                name="photos/jcr:primaryType"/>
 
Any inputs?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

The best practice to working with users in AEM is to use APIs located in the
org.apache.jackrabbit.api.security.user Java package. For example - to create a user use UserManager. 

2 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

The best practice to working with users in AEM is to use APIs located in the
org.apache.jackrabbit.api.security.user Java package. For example - to create a user use UserManager. 

viveksachdeva
Community Advisor
Community Advisor
October 16, 2015

But AccountManager has utilities to manage everything automatically. By simply passing a map, it creates user with profile properties. In UserManager it just creates a user but account information still needs to be persisted manually.

https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/security/AccountManager.html

It seems to be better than UserManger when it comes to persisting profile info along with registration.