[ajug-members] LDAP/JNDI auto reconnect ?

Sony Antony sony.antony at gmail.com
Wed Oct 18 11:43:50 EDT 2006


I was proceeding with creating a dynamic proxy object for dircontext.
but I was going to create/close the actual one against every method
call.
your idea of holding on to that till a connection exception occurs is
even better.
I think I will take it.
thanks a lot
--sony

On 10/18/06, Brian Lee <brian_a_lee at hotmail.com> wrote:
> Can you create an InitialContext proxy or facade that will catch exceptions
> and recreate the context when necessary? So instead of executing methods on
> the actual IC, you would call the proxy that will call the method, catch
> exception, recreate IC and call method on the new IC?
>
> BAL
>
> >From: "Sony Antony" <sony.antony at gmail.com>
> >To: "General AJUG membership forum (100-200
> >messages/month)"<ajug-members at ajug.org>
> >Subject: Re: [ajug-members] LDAP/JNDI auto reconnect ?
> >Date: Wed, 18 Oct 2006 08:44:17 -0400
> >
> >Thanks for the response Dan:
> >1. Actually we dont need failovers. It is OK for the application to be
> >down as long as the LDAP server is down. But we want the application
> >to be running normal when the ldap server come back.
> >
> >2. Also we cannot use pooling or any of the associated efatures like
> >maxlimit etc, because our is a library that will be used by others.
> >Since this code will be used in various managed environments (
> >webcontainers, ejbcontainers etc. ), we cannot set the system
> >properties ( -D switch for jvm ) as it might affect the behavior for
> >teh rest of the system.
> >
> >2. The only way I can think of is by using a dynamic proxy for the
> >DirContext object. The proxy method will instantiate a real DirContext
> >object at every call. It will then invoke the method on this object.
> >After the method, it will call close() on this object and return. But
> >since dynamic proxies are supported only in jdk 1.4, and some of our
> >groups still use jdk 1.3, I want to move in this direction only as the
> >last resort.
> >
> >
> >--sony
> >
> >
> >On 10/18/06, Dan Marchant <driedtoast at gmail.com> wrote:
> >>Also looking into the prefsize attribute for pooling, might be what you
> >>need.
> >>That manages the pool per identity.
> >>http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html
> >>
> >>
> >>
> >>On 10/18/06, Dan Marchant <driedtoast at gmail.com> wrote:
> >> > The sun api allows you to pass in multiple ldap connections separated
> >> > by a comma.
> >> > (At least it use to).
> >> >
> >> > This helps with failover, etc... Sounds like your problem is related
> >> > to failover.
> >> > You may want to have 2 directory servers with one acting as a failover
> >> > if the other goes down for maintainence, etc...
> >> >
> >> > Hope this helps,
> >> >
> >> > - Dan
> >> >
> >> >
> >> >
> >> > On 10/18/06, Sony Antony <sony.antony at gmail.com> wrote:
> >> > > Hello:
> >> > >
> >> > > We have some DirContext objects we hold on to. So that whenever we
> >> > > need to access ldap, we dont have to re-instantiate
> >>InitialDirContext.
> >> > >
> >> > > Or at least that was teh idea.
> >> > >
> >> > > Now we find that if teh ldap is restarted *after* this DirContext
> >> > > object is instantiated, this object becomes unusable.
> >> > > ( Because the peer side of the original TCP socket it has been
> >>holding
> >> > > on to has been closed )
> >> > > Is there a way around it ?
> >> > > We are using the usual "com.sun.jndi.ldap.LdapCtxFactory"
> >> > > which supports along with other things connection pooling.
> >> > >
> >> > > 1. Does it have something we can make use of ?
> >> > > 2. When we tried the following code, it didnt give us the pooled
> >>connections.
> >> > > It gave the pooled connections only when all the connection pool
> >> > > parameters were given as system properties through the -D switch.
> >> > > Since we dont want to specify these properties for the whole system,
> >> > > is there a way to overcome this
> >> > >
> >> > >
> >> > > Hashtable env = new Hashtable(11);
> >> > > env.put(Context.INITIAL_CONTEXT_FACTORY,"");
> >> > > env.put(Context.PROVIDER_URL, "ldap://hostname:2389/dc=blah..");
> >> > > env.put(DirContext.SECURITY_PRINCIPAL, "uid=somebody,...");
> >> > > env.put(DirContext.SECURITY_CREDENTIALS, "passwd");
> >> > > env.put("com.sun.jndi.ldap.connect.pool", "true");
> >> > > env.put("com.sun.jndi.ldap.connect.pool.initsize", "3");
> >> > > env.put("com.sun.jndi.ldap.connect.pool.debug", "fine");
> >> > > DirContext ctx = new InitialDirContext(env);
> >> > >
> >> > > Thanks for reading
> >> > >
> >> > > --sony
> >> > > _______________________________________________
> >> > > ajug-members mailing list
> >> > > ajug-members at ajug.org
> >> > > http://www.ajug.org/mailman/listinfo/ajug-members
> >> > >
> >> >
> >>_______________________________________________
> >>ajug-members mailing list
> >>ajug-members at ajug.org
> >>http://www.ajug.org/mailman/listinfo/ajug-members
> >>
> >_______________________________________________
> >ajug-members mailing list
> >ajug-members at ajug.org
> >http://www.ajug.org/mailman/listinfo/ajug-members
>
>
> _______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
>



More information about the ajug-members mailing list