Announcement Announcement Module
Collapse
No announcement yet.
reg : connection pooling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • reg : connection pooling

    While running my stress test I constantly stumble upon exceptions of this nature:

    org.springframework.ldap.CommunicationException: virt2:389; nested exception is javax.naming.CommunicationException: virt2:389 [Root exception is java.net.BindException: Address already in use: connect]
    at org.springframework.ldap.support.LdapUtils.convert LdapException(LdapUtils.java:98)
    at org.springframework.ldap.core.support.AbstractCont extSource.createContext(AbstractContextSource.java :266)
    at org.springframework.ldap.core.support.AbstractCont extSource.getContext(AbstractContextSource.java:10 6)
    at org.springframework.ldap.core.support.AbstractCont extSource.getReadOnlyContext(AbstractContextSource .java:125)
    at org.springframework.ldap.core.LdapTemplate.execute ReadOnly(LdapTemplate.java:792)
    at org.springframework.ldap.core.LdapTemplate.lookup( LdapTemplate.java:876)
    at com.ettex.rialto.dao.ClientDAOImpl.findByPrimaryKe y(ClientDAOImpl.java:161)
    at serverb.LDAPHelper.retrieveMSISDNFromLDAP(LDAPHelp er.java:115)
    at serverb.CustomerGatewayEnricher.enrich(CustomerGat ewayEnricher.java:34)
    at sun.reflect.GeneratedMethodAccessor45.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.camel.component.bean.MethodInfo.invoke( MethodInfo.java:214)
    at org.apache.camel.component.bean.MethodInfo$1.proce ed(MethodInfo.java:133)
    at org.apache.camel.component.bean.BeanProcessor.proc ess(BeanProcessor.java:137)
    at org.apache.camel.management.InstrumentationProcess or.process(InstrumentationProcessor.java:67)
    at org.apache.camel.processor.DelegateProcessor.proce ssNext(DelegateProcessor.java:53)
    at org.apache.camel.processor.DelegateProcessor.proce ed(DelegateProcessor.java:82)
    at org.apache.camel.processor.interceptor.TraceInterc eptor.process(TraceInterceptor.java:93)
    at org.apache.camel.management.InstrumentationProcess or.process(InstrumentationProcessor.java:67)
    at org.apache.camel.processor.RedeliveryErrorHandler. processExchange(RedeliveryErrorHandler.java:177)
    at org.apache.camel.processor.RedeliveryErrorHandler. processErrorHandler(RedeliveryErrorHandler.java:14 3)
    at org.apache.camel.processor.RedeliveryErrorHandler. process(RedeliveryErrorHandler.java:88)
    at org.apache.camel.processor.DeadLetterChannel.proce ss(DeadLetterChannel.java:56)
    at org.apache.camel.processor.DefaultChannel.process( DefaultChannel.java:228)
    at org.apache.camel.processor.Pipeline.process(Pipeli ne.java:74)
    at org.apache.camel.processor.UnitOfWorkProcessor.pro cessNext(UnitOfWorkProcessor.java:66)
    at org.apache.camel.processor.DelegateProcessor.proce ss(DelegateProcessor.java:48)
    at org.apache.camel.management.InstrumentationProcess or.process(InstrumentationProcessor.java:67)
    at org.apache.camel.component.direct.DirectProducer.p rocess(DirectProducer.java:45)
    at org.apache.camel.impl.ProducerCache$1.doInProducer (ProducerCache.java:179)
    at org.apache.camel.impl.ProducerCache$1.doInProducer (ProducerCache.java:161)
    at org.apache.camel.impl.ProducerCache.doInProducer(P roducerCache.java:146)
    at org.apache.camel.impl.ProducerCache.sendExchange(P roducerCache.java:160)
    at org.apache.camel.impl.ProducerCache.send(ProducerC ache.java:116)
    at org.apache.camel.impl.DefaultProducerTemplate.send (DefaultProducerTemplate.java:102)
    at org.apache.camel.impl.DefaultProducerTemplate.send Body(DefaultProducerTemplate.java:106)
    at org.apache.camel.impl.DefaultProducerTemplate.send Body(DefaultProducerTemplate.java:123)
    at org.apache.camel.impl.DefaultProducerTemplate.requ estBody(DefaultProducerTemplate.java:271)
    at serverb.MultiServerThread.run(MultiServerThread.ja va:81)
    Caused by: javax.naming.CommunicationException: virt2:389 [Root exception is java.net.BindException: Address already in use: connect]
    at com.sun.jndi.ldap.Connection.<init>(Connection.jav a:210)
    at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.jav a:118)
    at com.sun.jndi.ldap.LdapClient.getInstance(LdapClien t.java:1580)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:265 2)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapC txFactory.java:175)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Ldap CtxFactory.java:193)
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstanc e(LdapCtxFactory.java:136)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext (LdapCtxFactory.java:66)
    at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:667)
    at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:288)
    at javax.naming.InitialContext.init(InitialContext.ja va:223)
    at javax.naming.ldap.InitialLdapContext.<init>(Initia lLdapContext.java:134)
    at org.springframework.ldap.core.support.LdapContextS ource.getDirContextInstance(LdapContextSource.java :43)
    at org.springframework.ldap.core.support.AbstractCont extSource.createContext(AbstractContextSource.java :254)
    ... 38 more
    Caused by: java.net.BindException: Address already in use: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl .java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSoc ketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
    at java.net.Socket.connect(Socket.java:525)
    at java.net.Socket.connect(Socket.java:475)
    at java.net.Socket.<init>(Socket.java:372)
    at java.net.Socket.<init>(Socket.java:186)
    at com.sun.jndi.ldap.Connection.createSocket(Connecti on.java:352)
    at com.sun.jndi.ldap.Connection.<init>(Connection.jav a:187)
    ... 52 more

    It only happens if I use LDAP intensively. So the question would be, is there any way to prevent “Address already in use” exceptions?

    I think it is related to connection pooling. I posted my springldap.xml. Can someone please tell me what changes i have to make to the xml file to prevent the above exception.

    springldap.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapC ontextSource">
    <property name="url" value="${ldap.url}" />
    <property name="base" value="${ldap.base}" />
    <property name="userDn" value="${ldap.userDn}" />
    <property name="password" value="${ldap.password}" />
    </bean>

    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
    <constructor-arg ref="contextSource" />
    </bean>
    ...

  • #2
    Hi,
    I'm having the same issue, did you solve it ?

    Comment


    • #3
      <bean id="contextSource" class="org.springframework.ldap.pool.factory.Pooli ngContextSource">
      <property name="contextSource" ref="contextSourceTarget" />
      </bean>

      <bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapC ontextSource">
      <property name="url" value="ldap://xxx.com:389" />
      <property name="base" value="dc=xxx,dc=com" />
      <property name="userDn" value="uid=bind,ou=System,dc=xxx,dc=com" />
      <property name="password" value="bind" />
      <property name="pooled" value="false"></property>
      </bean>


      <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
      <constructor-arg ref="contextSource" />
      </bean>

      <bean id="springLDAPService" class="xxx.service.impl.SpringLDAPServiceImpl">
      <property name="ldapTemplate" ref="ldapTemplate" />
      <property name="contextSource" ref="contextSource"></property>
      </bean>
      http://static.springsource.org/sprin...l/pooling.html

      if u want to use the pooling this is context.xml and follow the link

      Comment

      Working...
      X