Reposting: LDAP callback functionality error | Community
Skip to main content
October 16, 2015
Solved

Reposting: LDAP callback functionality error

  • October 16, 2015
  • 1 reply
  • 1255 views

Do not know why my question was deleted.

I've configured LDAP Callback functionality in CQ5.6.1 and my code is as below -

public class SyncUser implements com.day.crx.security.ldap.sync.Callback{ @Override public void onUserSync(User userToBeSynched, Map<String, Value[]> attributes, ValueFactory valueFactory) throws RepositoryException { Iterator iter = attributes.entrySet().iterator(); while (iter.hasNext()) { Map.Entry mEntry = (Map.Entry) iter.next(); javax.jcr.Value val =  (javax.jcr.Value)mEntry.getValue(); // Error** [Ljavax.jcr.Value; cannot be cast to javax.jcr.Value System.out.println(mEntry.getKey() + " : " + val.getString()); } }

 I'm getting error while type casting Value object to fetch all the entries from map.  

java.lang.ClassCastException: [Ljavax.jcr.Value; cannot be cast to javax.jcr.Val
ue
        at com.ldaptest.SyncUser.onUserSync(SyncUser.java:76)
        at com.day.crx.security.ldap.LDAPUserSync$SyncOperation.notifyCallback(L
DAPUserSync.java:697)
        at com.day.crx.security.ldap.LDAPUserSync$SyncOperation.sync(LDAPUserSyn
c.java:509)
        at com.day.crx.security.ldap.LDAPUserSync$SyncOperation.syncUser(LDAPUse
rSync.java:430)
        at com.day.crx.security.ldap.LDAPUserSync$SyncUserOperation.sync(LDAPUse
rSync.java:345)
        at com.day.crx.security.ldap.LDAPUserSync$SyncOperation.initAndSync(LDAP
UserSync.java:419)
        at com.day.crx.security.ldap.LDAPUserSync.performUpdate(LDAPUserSync.jav
a:264)
        at com.day.crx.security.ldap.LDAPUserSync.syncUser(LDAPUserSync.java:173
)
        at com.day.crx.security.ldap.LDAPLoginModule.commit(LDAPLoginModule.java
:364)

 

Appriciate your help. Many thanks!

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 rakesh_kumar1

java.lang.ClassCastException: [Ljavax.jcr.Value; cannot be cast to javax.jcr.Val
ue

javax.jcr.Value val =  (javax.jcr.Value)mEntry.getValue();

 

mEntry.getValue() is an Array, you cannot cast it to a  javax.jcr.Value.

 

Just iterate over the returned array and see.

 

HTH.

 

Rakesh.

1 reply

rakesh_kumar1
rakesh_kumar1Accepted solution
Level 2
October 16, 2015

java.lang.ClassCastException: [Ljavax.jcr.Value; cannot be cast to javax.jcr.Val
ue

javax.jcr.Value val =  (javax.jcr.Value)mEntry.getValue();

 

mEntry.getValue() is an Array, you cannot cast it to a  javax.jcr.Value.

 

Just iterate over the returned array and see.

 

HTH.

 

Rakesh.