javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name ''

Spring JIRA | Timothy | 5 years ago
  1. 0

    In the DefaultDirContextValidator class the validateObject method catches this exception when an object in the object pool has become invalid. This is an expected outcome and is handled by the framework. The problem is that when caught the exception is logged as a warning and the exception stack trace dumped to the logs, as this is not a rare event logs are subsiquently littered with this stacktrace and warnings. Notes: ------ We use DefaultDirContextValidator in conjunction with the testOnBorrow Pooling setting. Offending Code: --------------- catch (Exception e) { this.logger.warn("DirContext '" + dirContext + "' failed validation with an exception.", e); } if (this.logger.isInfoEnabled()) { this.logger.info("DirContext '" + dirContext + "' failed validation."); } Stack Trace: ------------ [11/07/11 09:01:53:070 EST] 00000077 DefaultDirCon I org.springframework.ldap.pool.validation.DefaultDirContextValidator validateDirContext DirContext 'javax.naming.ldap.InitialLdapContext@1ace4fd' failed validation. [11/07/11 09:08:59:130 EST] 00000085 DefaultDirCon W org.springframework.ldap.pool.validation.DefaultDirContextValidator validateDirContext DirContext 'javax.naming.ldap.InitialLdapContext@14e0984' failed validation with an exception. javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name '' at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1973) at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1818) at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1743) at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313) at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238) 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:780) 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.executeReadOnly(LdapTemplate.java:770) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:865)

    Spring JIRA | 5 years ago | Timothy
    javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name ''
  2. 0

    LDAP-230: Pool Validation polluting logs with "IOException: connection closed" stacktrace even though it is handled gracefully by framework

    GitHub | 5 years ago | spring-issuemaster
    javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name ''
  3. 0

    In the DefaultDirContextValidator class the validateObject method catches this exception when an object in the object pool has become invalid. This is an expected outcome and is handled by the framework. The problem is that when caught the exception is logged as a warning and the exception stack trace dumped to the logs, as this is not a rare event logs are subsiquently littered with this stacktrace and warnings. Notes: ------ We use DefaultDirContextValidator in conjunction with the testOnBorrow Pooling setting. Offending Code: --------------- catch (Exception e) { this.logger.warn("DirContext '" + dirContext + "' failed validation with an exception.", e); } if (this.logger.isInfoEnabled()) { this.logger.info("DirContext '" + dirContext + "' failed validation."); } Stack Trace: ------------ [11/07/11 09:01:53:070 EST] 00000077 DefaultDirCon I org.springframework.ldap.pool.validation.DefaultDirContextValidator validateDirContext DirContext 'javax.naming.ldap.InitialLdapContext@1ace4fd' failed validation. [11/07/11 09:08:59:130 EST] 00000085 DefaultDirCon W org.springframework.ldap.pool.validation.DefaultDirContextValidator validateDirContext DirContext 'javax.naming.ldap.InitialLdapContext@14e0984' failed validation with an exception. javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name '' at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1973) at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1818) at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1743) at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313) at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238) 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:780) 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.executeReadOnly(LdapTemplate.java:770) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:865)

    Spring JIRA | 5 years ago | Timothy
    javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name ''
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to reconnect when the LDAP server is restarted?

    Stack Overflow | 5 years ago | Anand
    javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name 'uid=foo,ou=People,dc=example,dc=com'

    3 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. javax.naming.CommunicationException

      connection closed [Root exception is java.io.IOException: connection closed]; remaining name ''

      at com.sun.jndi.ldap.LdapCtx.doSearch()
    2. Java RT
      InitialDirContext.search
      1. com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1973)
      2. com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1818)
      3. com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1743)
      4. com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
      5. com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
      6. com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
      7. javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
      7 frames
    3. spring-ldap-core
      DirContextPoolableObjectFactory.validateObject
      1. org.springframework.ldap.pool.validation.DefaultDirContextValidator.validateDirContext(DefaultDirContextValidator.java:154)
      2. org.springframework.ldap.pool.factory.DirContextPoolableObjectFactory.validateObject(DirContextPoolableObjectFactory.java:169)
      2 frames
    4. Commons Pool
      GenericKeyedObjectPool.borrowObject
      1. org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:780)
      1 frame
    5. spring-ldap-core
      LdapTemplate.lookup
      1. org.springframework.ldap.pool.factory.PoolingContextSource.getContext(PoolingContextSource.java:394)
      2. org.springframework.ldap.pool.factory.PoolingContextSource.getReadOnlyContext(PoolingContextSource.java:374)
      3. org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:770)
      4. org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:865)
      4 frames