java.lang.ClassCastException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I have configuration something like this, <bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapContextSource"> <property name="urls" value="${ldapconnection.urls}" /> <property name="base" value="${ldapconnection.base}" /> <property name="userDn" value="${ldapconnection.userDn}" /> <property name="password" value="${ldapconnection.password}" /> <property name="pooled" value="false"/> <property name="baseEnvironmentProperties"> <map> <entry key="com.sun.jndi.ldap.connect.timeout" value="${ldapconnection.timeout}" /> </map> </property> </bean> <bean id="dirContextValidator" class="org.springframework.ldap.pool.validation.DefaultDirContextValidator" /> <bean id="contextSource" class="org.springframework.ldap.pool.factory.PoolingContextSource"> <property name="contextSource" ref="contextSourceTarget" /> <property name="dirContextValidator" ref="dirContextValidator" /> <property name="testOnBorrow" value="${ldappool.testOnBorrow}" /> <property name="testWhileIdle" value="${ldappool.testWhileIdle}" /> <property name="minIdle" value="${ldappool.minIdle}" /> <property name="maxIdle" value="${ldappool.maxIdle}" /> <property name="maxActive" value="${ldappool.maxActive}" /> <property name="maxWait" value="${ldappool.maxWait}" /> <property name="whenExhaustedAction" value="${ldappool.whenExhaustedAction}" /> <property name="timeBetweenEvictionRunsMillis" value="${ldappool.timeBetweenEvictionRunsMillis}" /> <property name="minEvictableIdleTimeMillis" value="${ldappool.minEvictableIdleTimeMillis}" /> <property name="numTestsPerEvictionRun" value="${ldappool.numTestsPerEvictionRun}" /> </bean> <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"> <constructor-arg ref="contextSource" /> </bean> <bean id="tripletContextMapper" class="com.anand.MyContextMapper"> <property name="name" value="name" /> </bean> <bean id="ldapSearch" class="com.anand.LDAPSearch"> <property name="searchDn" value="${search.Dn}" /> <property name="tripletContextMapper" ref="tripletContextMapper" /> </bean> </beans> From above, You can see that, I have not configured any DirObjectFactory but still getting ClassCastException as shown below, 1|localhost|MyAdapter|2009-06-16 17:54:49|ldap search error: : null java.lang.ClassCastException at org.springframework.ldap.core.support.AbstractContextMapper.mapFromContext(AbstractContextMapper.java:43) at org.springframework.ldap.core.LdapTemplate$14.executeWithContext(LdapTemplate.java:869) at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:784) at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:771) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:865)
    via by anand ramadurg,
  • I have configuration something like this, <bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapContextSource"> <property name="urls" value="${ldapconnection.urls}" /> <property name="base" value="${ldapconnection.base}" /> <property name="userDn" value="${ldapconnection.userDn}" /> <property name="password" value="${ldapconnection.password}" /> <property name="pooled" value="false"/> <property name="baseEnvironmentProperties"> <map> <entry key="com.sun.jndi.ldap.connect.timeout" value="${ldapconnection.timeout}" /> </map> </property> </bean> <bean id="dirContextValidator" class="org.springframework.ldap.pool.validation.DefaultDirContextValidator" /> <bean id="contextSource" class="org.springframework.ldap.pool.factory.PoolingContextSource"> <property name="contextSource" ref="contextSourceTarget" /> <property name="dirContextValidator" ref="dirContextValidator" /> <property name="testOnBorrow" value="${ldappool.testOnBorrow}" /> <property name="testWhileIdle" value="${ldappool.testWhileIdle}" /> <property name="minIdle" value="${ldappool.minIdle}" /> <property name="maxIdle" value="${ldappool.maxIdle}" /> <property name="maxActive" value="${ldappool.maxActive}" /> <property name="maxWait" value="${ldappool.maxWait}" /> <property name="whenExhaustedAction" value="${ldappool.whenExhaustedAction}" /> <property name="timeBetweenEvictionRunsMillis" value="${ldappool.timeBetweenEvictionRunsMillis}" /> <property name="minEvictableIdleTimeMillis" value="${ldappool.minEvictableIdleTimeMillis}" /> <property name="numTestsPerEvictionRun" value="${ldappool.numTestsPerEvictionRun}" /> </bean> <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"> <constructor-arg ref="contextSource" /> </bean> <bean id="tripletContextMapper" class="com.anand.MyContextMapper"> <property name="name" value="name" /> </bean> <bean id="ldapSearch" class="com.anand.LDAPSearch"> <property name="searchDn" value="${search.Dn}" /> <property name="tripletContextMapper" ref="tripletContextMapper" /> </bean> </beans> From above, You can see that, I have not configured any DirObjectFactory but still getting ClassCastException as shown below, 1|localhost|MyAdapter|2009-06-16 17:54:49|ldap search error: : null java.lang.ClassCastException at org.springframework.ldap.core.support.AbstractContextMapper.mapFromContext(AbstractContextMapper.java:43) at org.springframework.ldap.core.LdapTemplate$14.executeWithContext(LdapTemplate.java:869) at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:784) at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:771) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:865)
    via by anand ramadurg,
    • java.lang.ClassCastException at org.springframework.ldap.core.support.AbstractContextMapper.mapFromContext(AbstractContextMapper.java:43) at org.springframework.ldap.core.LdapTemplate$14.executeWithContext(LdapTemplate.java:869) at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:784) at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:771) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:865)
    No Bugmate found.