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

  • MutablePoolingContextSource failing dir context validation

    Hello,

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

    Code:
    	<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>
    		<property name="maxTotal" value="1" />
    		<property name="testOnBorrow" value="true"/>
    		<property name="testWhileIdle" value="true"/>
    	</bean>	
    	
    	<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    		<constructor-arg ref="poolingContextSource" />
    	</bean>
    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
    Code:
    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:
    Code:
    12750 [main] WARN org.springframework.ldap.pool.validation.DefaultDirContextValidator - DirContext 'javax.naming.ldap.InitialLdapContext@326cbb2d' 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(LdapCtx.java:3101)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794)
    	at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1826)
    	at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1749)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:321)
    	at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:248)
    	at org.springframework.ldap.pool.validation.DefaultDirContextValidator.validateDirContext(DefaultDirContextValidator.java:166)
    	at org.springframework.ldap.pool.factory.DirContextPoolableObjectFactory.validateObject(DirContextPoolableObjectFactory.java:169)
    	at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1197)
    	at org.springframework.ldap.pool.factory.MutablePoolingContextSource.getContext(MutablePoolingContextSource.java:37)
    	at org.springframework.ldap.pool.factory.PoolingContextSource.getReadOnlyContext(PoolingContextSource.java:401)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:287)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:259)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:606)
    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.
Working...
X