Announcement Announcement Module
No announcement yet.
MutablePoolingContextSource failing dir context validation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • MutablePoolingContextSource failing dir context validation


    I am using MutablePoolingContextSource with a single connection to perform paged searches against Active Directory. I am using the configuration suggested in LDAP-153:

    	<bean id="poolingContextSource" class="org.springframework.ldap.pool.factory.MutablePoolingContextSource">
    		<property name="contextSource" ref="contextSource" />
    		<property name="dirContextValidator">
    			<bean class="org.springframework.ldap.pool.validation.DefaultDirContextValidator" />
    		<property name="maxTotal" value="1" />
    		<property name="testOnBorrow" value="true"/>
    		<property name="testWhileIdle" value="true"/>
    	<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    		<constructor-arg ref="poolingContextSource" />
    The problem I am seeing is that I can only successfully retrieve two pages. When I try to retrieve the third page, it fails with
    org.springframework.ldap.OperationNotSupportedException: [LDAP: error code 12 - 00000057: LdapErr: DSID-0C090745, comment: Error processing control, data 0, v1db0.
    In the log file, the same exception is also being thrown when the pool checks for a valid connection during the "testOnBorrow" step:
    12750 [main] WARN org.springframework.ldap.pool.validation.DefaultDirContextValidator - DirContext '[email protected]' failed validation with an exception.
    javax.naming.OperationNotSupportedException: [LDAP: error code 12 - 00000057: LdapErr: DSID-0C090745, comment: Error processing control, data 0, v1db0
    	at com.sun.jndi.ldap.LdapCtx.mapErrorCode(
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(
    	at com.sun.jndi.ldap.LdapCtx.searchAux(
    	at com.sun.jndi.ldap.LdapCtx.c_search(
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(
    	at org.springframework.ldap.pool.validation.DefaultDirContextValidator.validateDirContext(
    	at org.springframework.ldap.pool.factory.DirContextPoolableObjectFactory.validateObject(
    	at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(
    	at org.springframework.ldap.pool.factory.MutablePoolingContextSource.getContext(
    	at org.springframework.ldap.pool.factory.PoolingContextSource.getReadOnlyContext(
    It seems that the Request Control being set on the LdapContext for the paging is never reset. Therefore, when the DefaultDirContextValidator sends the search request to perform the validation, it is issuing it with the PagedResultsControl that was set in the prior call. This would explain why it always fails on the third request. The first validation is sent with no Request Control set. The second validation is sent with a PagedResultsControl with a null cookie. The third validation is sent with a PagedResultsControl with an invalid cookie since those results were already retrieved, and hence the exception.

    Is the Request Control for the LdapContext supposed to be reset after each call? I saw that some users have used MutablePoolingContextSource successfully, but I don't understand why it would work for them.
    Last edited by aschen77; Apr 24th, 2012, 09:15 PM.