Announcement Announcement Module
Collapse
No announcement yet.
Fail validation - DefaultDirContextValidator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fail validation - DefaultDirContextValidator

    Here's the scenario:
    Under my current configuration everything seems to work fine.... then the following validation exception occurs. It keeps on throwing it for a bit.... then after awhile (few minutes) it starts working again and doesn't throw the exception.

    Code:
    [4/23/08 12:01:21:270 CDT] 00000078 DefaultDirCon W org.springframework.ldap.pool.validation.DefaultDirContextValidator validateDirContext DirContext 'javax.naming.ldap.InitialLdapContext@61826ca7' failed validation with an exception.
                                     javax.naming.CommunicationException: connection closed.  Root exception is java.io.IOException: connection closed
    	at com.sun.jndi.ldap.LdapClient.ensureOpen(LdapClient.java(Compiled Code))
    	at com.sun.jndi.ldap.LdapClient.search(LdapClient.java(Compiled Code))
    	at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java(Compiled Code))
    	at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java(Compiled Code))
    	at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1751)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:386)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:347)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:332)
    	at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:252)
    	at org.springframework.ldap.pool.validation.DefaultDirContextValidator.validateDirContext(DefaultDirContextValidator.java:154)
    	at org.springframework.ldap.pool.factory.DirContextPoolableObjectFactory.validateObject(DirContextPoolableObjectFactory.java:169)
    	at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:837)
    	at org.springframework.ldap.pool.factory.PoolingContextSource.getContext(PoolingContextSource.java:394)
    	at org.springframework.ldap.pool.factory.PoolingContextSource.getReadOnlyContext(PoolingContextSource.java:374)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:266)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:213)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:601)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:509)
    	at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:435)
    As you can see I've enabled the testOnBorrow configuration, which I thought should validate the context.... and if it fails.... create a new one. Now the question is..... when it fails, does it throw the exception (like the one above) then continue to create a new connection? Or is that all under the covers and the exeption I have is unrelated?

    Here is my config:

    Code:
    	<!-- LDAP Context   -->
    	<bean id="contextSource" class="org.springframework.ldap.pool.factory.PoolingContextSource">
    		<property name="contextSource" ref="contextSourceTarget"/>
    		<property name="dirContextValidator" ref="dirContextValidator"/>
    		<property name="testOnBorrow" value="true"/>
    		<property name="testWhileIdle" value="false"/>
    		<property name="maxActive" value="8"/>
    		<property name="maxTotal" value="-1"/>
    		<property name="maxIdle" value="8"/>
    		<property name="maxWait" value="-1"/>
    		<property name="whenExhaustedAction" value="1"/>
    		
    	</bean>
    
    	<bean id="dirContextValidator" class="org.springframework.ldap.pool.validation.DefaultDirContextValidator"/>
    		
    	<bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapContextSource">
          <property name="url" value="#{ldap.url}" />
          <property name="base" value="#{ldap.base}" />
            <property name="userDn" value="#{ldap.userDn}" />
          <property name="password" value="#{ldap.password}" />
          <property name="pooled" value="false"/>
          <property name="baseEnvironmentProperties">
    		  <map>
    		  <entry key="java.naming.ldap.attributes.binary" value="objectGUID"/>
    		  </map> 
    	  </property> 
    	 
       </bean>
    
       <!-- LDAP Template  -->
    	<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
          <constructor-arg ref="contextSource" />
          <property name="ignorePartialResultException" value="true" />
       </bean>
    Thanks in advance

  • #2
    I'm not clear from your message.

    Does the application fail while this message is being logged?

    Comment


    • #3
      Well, I've had reports that the application failed and the only exceptions in the log during the time frame are these Validation exceptions. I suppose it could be something else, but at this point, I have to rule out these communication exceptions.

      Perhaps I can rule out the pooling if I could monitor the connections or log the creation and release of them.
      I've read that when using the jndi pooling I could use the following java option:
      -Dcom.sun.jndi.ldap.connect.pool.debug=fine
      but this doesn't sound like it'd work with the spring ldap pooling since we turn the jndi pooling off.

      Is there some other way of monitoring connections.... other than doing a netstat?

      Thanks!
      Last edited by hasdy; Apr 24th, 2008, 11:03 AM.

      Comment


      • #4
        You can simply turn logging up to DEBUG for the org.springframework.ldap.pool package. The pool and validator log connection creation, validation and destruction.

        Your config has pooling set to false on the targetContextSource which is correct, are you setting any of the JVM LDAP pooling system properties? If so you should not, the JVM LDAP pooling is not robust and would likely cause even more problems when using the pooling context source on top of it.

        Comment


        • #5
          thanks for the response:
          I haven't actually set any system properties for the jvm ldap pooling.

          and perhaps I'm being dense, but how do i go about turning up logging to DEBUG for that package? Is this a configuration?
          ie : <property name="log" value="DEBUG"/> for the pooling context?

          or is this something I'd set on the server itself?

          Thanks!

          Comment


          • #6
            One way would be to place log4j.jar and a log4j.properties file in your classpath, containing something like this:

            Code:
            ### direct log messages to stdout ###
            log4j.appender.stdout=org.apache.log4j.ConsoleAppender
            log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
            log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{1}:%L - %m%n
            
            ### set log levels - for more verbose logging change 'info' to 'debug' ###
            log4j.rootLogger=info, stdout
            
            ### enable spring ldap pooling logging
            log4j.logger.org.springframework.ldap.pool=debug

            Comment


            • #7
              Thanks for the reply ulsa.

              I've added log4j to my project (properties and jar file). I've also added PropertyConfigurator.configure(properties) to a servlet init method.

              But I'm still not getting any logging from the pool package.

              I know the logging is working since I've added a couple of test log statements and it shows up on the SystemOut.log (and console).

              I've taken a look at the source for the classes in the pool package and there doesn't seem to be any log statements. Isn't this required?

              Or when edalquist suggested that turn on DEBUG for the pool package, he meant that I should also add some debug logging statements?

              Thanks!

              Comment


              • #8
                There are logging statements in the pool validator and poolable object factory which do the interesting work related to connection pooling.

                There is a bug in the config posted above, I believe it should look like:

                Code:
                ### direct log messages to stdout ###
                log4j.appender.stdout=org.apache.log4j.ConsoleAppender
                log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
                log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{1}:%L - %m%n
                
                ### set log levels - for more verbose logging change 'info' to 'debug' ###
                log4j.rootLogger=info, stdout
                
                ### enable spring ldap pooling logging
                log4j.logger.org.springframework.ldap.pool=debug, stdout
                Note the addition of the appender name on the last line.

                Comment

                Working...
                X