Losing servlet-ldap connection

Hi,
The problem :
I have a servlet that accesses an Ldap server (iplanet). The servlet loses the ldap connection after being unsused for a long while.
What I tried :
I implemented my own method (isConnected(), see the code below) to check the connection : this method performs a silly search in the Ldap. I call this method before any other call to the Ldap. When the connection is lost, the method hangs for a long while (more than 5 minutes) although I set the serverTimeLimit parameter to 10 seconds. The servlet is hanging during the call to the search method of the Ldap.
The question :
Do you know the ways to check if the ldap connection is still valid or not ?
The details :
Environment : Unix, Solaris 8
Tomcat server 4.1
Iplanet 5.1
Ldap access : SDK
The code :
* isConnected()
* Test the Ldap connection trying to perform a search request
* @author mba
* @version
public boolean isConnected()
boolean zb_IsConnected = true;
// Test the connection with a request
try
String lDN = "ObjectName=*";
String lFilter = "(ObjectName=*)";
String lAttrs[] = {"ObjectID"};
mLDAP.getSearchConstraints().setServerTimeLimit(10);
LDAPSearchResults lResults = mLDAP.search (mSwitchDir, LDAPConnection.SCOPE_ONE, lFilter, lAttrs, false);
catch (LDAPException e)
if( (e.getLDAPResultCode() == LDAPException.SERVER_DOWN) ||
(e.getLDAPResultCode() == LDAPException.CONNECT_ERROR) ||
(e.getLDAPResultCode() == LDAPException.CONNECT_ERROR) ||
(e.getLDAPResultCode() == LDAPException.TIME_LIMIT_EXCEEDED) ||           
(e.getLDAPResultCode() != LDAPException.SUCCESS) )
if(!reconnect())
System.out.println("ldapMain::isConnected() - Error, failed to reconnect");          
          zb_IsConnected = false;
return zb_IsConnected;
}

Hi All,
I am working on a project which uses jsp and ldap. I am getting a very strange kind of error, sometimes for LDAP operation error called SERVER_DOWN(80) is coming it it goes if I refresh the page. behaviour of this error is very uncertain sometimes it comes and sometimes it does not come.
Does anybody has any idea how to solve? is it something related to LDAP server settings or memory leaks. please guide
thanks in advance
-presi

Similar Messages

  • Determining the state of an LDAP connection

    Hi all,
    I'm in a situation where I need to determine the state of an existing LDAP connection. The code is called from Java servlets / JSP's, and we're having a problem where the client mysteriously disconnects. The stack trace points to:
    04/10/04 10:24:54 javax.naming.CommunicationException: connection closed. Root exception is java.io.IOException: connection closed
    04/10/04 10:24:54 at com.sun.jndi.ldap.LdapClient.ensureOpen(LdapClient.java:1648)
    04/10/04 10:24:54 at com.sun.jndi.ldap.LdapClient.search(LdapClient.java:594)
    04/10/04 10:24:54 at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1921)
    04/10/04 10:24:54 at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1783)
    04/10/04 10:24:54 at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1708)
    04/10/04 10:24:54 at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
    04/10/04 10:24:54 at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
    04/10/04 10:24:54 at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
    04/10/04 10:24:54 at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
    04/10/04 10:24:54 at com.tekelec.corpdir.ad.ADHelper.getAvailableOrgUnits(ADHelper.java:582)
    The peculiar thing is that the InitialDirContext DOES exist, and is not null. Since we can't poinpoint what is causing the disconnects, the next best thing is to to a test against the context to determine if it is still connected.
    Looking at this stack trace, I can see a function: com.sun.jndi.ldap.LdapClient.ensureOpen(LdapClient.java:1648)
    Googling the source, shows the following implementation:
    private void ensureOpen() throws IOException {
         if (conn == null) {
         throw new IOException("connection closed");
    However, this does no good, since the function is private, and the corresponding Connection object is not exposed through JNDI.
    Does anyone have any ideas? For now, I'm going to just call a simple 'lookup(...)' to cause the exception to be thrown if the connection is dead.
    TIA!
    -Sean

    I was getting this exception on relatively large searches (but not on smaller ones). I was also getting a java.lang.OutOfMemoryError just before it that wasn't part of the stack trace. The server was nowhere near running out of swap, and all the /etc/system parameters (solaris) were reasonable.
    Then I found this page:
    http://java.sun.com/docs/hotspot/PerformanceFAQ.html#171
    and changed the way I'm calling the jvm this way:
    /usr/local/j2sdk1.4.2_08/bin/java -Xms512m -Xmx512m <java class file>
    This solved the problem for me. Something you may want to try, anyway.

  • Issue with LDAP Connection becuase of Network issue

    Hello All,
    We have some network issues going on which is causing the NIC (Network interface card) to failover to another NIC. Due to this failover SUN access manager's LDAP connection pool fills up and we see errors in logs "Directory is down". We have to restart the Access manager to resolve this issue which refresh the connection pool of LDAP.
    Now we have set the setting as recommended in admin guide/tuning guide. Like
    1. Set event connection idle timeout to less that firewall or loadbalancer idle timeout value.
    2. event connection retry count and interval on perticular error code.
    Despite of above settings its not working out. Is there other way to get all the stale connections back to the LDAP pool without restarting the server?
    Or something which handles the network failover or failback?
    Regards
    Chetan Kulshrestha

    The user search name is the value you should be looking at in the LDAP attributes, that's the one that it will send to LDAP on a logon attempt. If you changed this value after mapping a group, I'm not sure but you may have to remap the group to get the change.
    So on the LDAP side verify the user search attribute = the username you expect to login with (i.e. cn, samaccountname, uid, etc)
    Regards,
    Tim

  • How to disable SSLv3 and keep only TLS for LDAP connection.

    Hi,
    I'm planning to keep only TLSv1.2 for LDAP connections.
    I tried to set LDAP_OPT_SSL_INFO in LDAP Session Options using a SecPkgContext_ConnectionInfo Structure with dwProtocol SP_PROT_TLS1_2_CLIENT(as described here -  https://social.msdn.microsoft.com/Forums/en-US/7544226d-97e1-4dae-a377-e382c2281e91/how-to-set-up-tls-in-ldap-connection?forum=vcgeneral),
    but it returns LDAP_PARAM_ERROR.
    I tried to call this function directly after ldap_sslinit/ldap_init and before ldap_connect() - without success, I tried to use other parameters with default values, I tried to initialize them by 0/other possible values - and also no success.
    How I can do this?
    Thanks for your advices.

    LDAP_PARAM_ERROR
    https://msdn.microsoft.com/en-us/library/aa367026(v=vs.85).aspx

  • Servlets/JDBC - Connect to database ONCE and not in every servlet - How?

    Hello, I'm using servlets and JDBC.
    In every servlet , i connect to the database and then i close the connection, but this is not ptactical.
    I would like to connect to the database once (at the beginning) when container starts and then close the connection.
    How am i supposed to do that?
    Thanks, in advance!

    Bad idea. Don't do that. The connection will timeout sooner or later (depends on DB used, it's usually around 30 mins) and your application will crash.
    You should always acquire and close the connection (and statement and resultset!) in the shortest possible scope. To improve connecting performance just use connection pooling.
    Create a DAO class which does all the task and just instantiate and assign it as Servlet class variable during Servlet's init() method. For more insights and code samples start here: [http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html].
    To go back to your fundamental question, doing some stuff during startup and shutdown of webapp, you could use the ServletContextListener for this. But again, do NOT do this to get hold of an external resource such as a connection! It's receipt for trouble.

  • I bought a new MacBook Pro several months ago.  I keep losing my wireless connection (my wife, sitting several feet from me has no problem with her iPad2).  I find the quickest fix ix to turn Airport off and back on.  Very annoying.   Suggestions please?

    I bought a new MacBook Pro several months ago.  I keep losing my wireless connection (my wife, sitting several feet from me has no problem with her iPad2).  I find the quickest fix ix to turn Airport off and back on.  Very annoying.   Suggestions please?

    What kind of wireless router are you using? more importantly which protocol are you connecting with? Are you and wife connecting using the 2.4Ghz band? or do you have a dual band router that offers the 5GHZ band?  Are you both connecting vie 802.11 a/b/g or n?
    The best thing to do is to go into SYSTEM PREFERENCES and select NETWORK, then select AIRPORT and click on the ADVANCED button.
    Under the AirPort tab you should delete all the preferred networks and only add back in your network with the proper security settings and passwords.
    If you hold down the option key on your keyboard while clicking on the airport icon at the top on your macbook pro. you'll seesome data that will tell you what band and mode you're connecting at, as well as in an indication of signal strength (RSSI) if you write down and post back that information it'll tell us what's going on.

  • After updating to ios 8 i keep losing my internet connection, and have to restart every time?

    After updating my ipad mini to ios 8, i keep losing my internet connection and have to restart.

    Hi Turn Router off for  30 seconds Goto Settings Reset Network Settings After reset you need to enter your router wireless key. Also later check on website for a Firmware update for your router. Cheers Brian

  • NullPointerException at com.sun.jndi.ldap.Connection.run(Connection.java:52

    We are using the Sun jndi 1.2.1 files from a Java client to
    access the IBM SecureWay Directory 3.2 server. Our test case is
    retrieving entries using the ctx.getAttributes (String, String[])
    method. Occasionally we are receiving the following error.
    java.lang.NullPointerException
    at com.sun.jndi.ldap.Connection.run(Connection.java:525)
    at java.lang.Thread.run(Thread.java:481)
    The java.lang.NullPointerException is coming from the Sun JNDI file.
    Our program is not catching this exception.
    Has anyone seen this problem before and have any ideas on how this can be resolved?

    Download and use LDAP 1.2.3 or JDK 1.3.1.
    The problem should go away.

  • LDAP connections with multiple proxy instances

    After configuring LDAP connectivity through the Admin application on a machine with multiple proxy instances I end up with:
    number of proxy instances x LDAPConnPool times number of connections to the LDAP server.
    Question: Is it possible to prevent some of the proxy instances from opening LDAP connections?

    Hi
    Increase the IDLE timeout value on the LDAP server. Of course, this just extends the inevitable. Check if there is a way to disable IDLE timeout on LDAP server.
    Regards,
    Nagendra HK

  • LDAP connectivity in web Dynpro

    How to do  LDAP connectivity in web dynpro to make use of UME

    After installing the LDAP go to configtool UME
    Select the option from the dropdown
    then
    Provide the server name : The server in which you have installed the LDAP
    port :389/636
    username=cn=<the username>,o=<context name>
    password=<the passsword provided by you while installing>
    browse to find the data for the path below
    userpath
    grouppath
    After this the UME in portal can be configured in the LDAP

  • Satelite C660 keeps losing its wireless connection

    Hi
    We have bought the above laptop for our son for christmas and it keeps losing its wireless connection, we also have a Satelite L450 which is running fine (not losing internet connection) we have been onto our broadband supplier they have told us that as the wireless connection on our other laptop is fine, it is something to do with the C660, one of the drivers needs an update, unfortuneately I have forgotten the driver name but it is something to do with the modem, Our son is desperate to use his laptop.
    Can anyone help?

    Had the same problem but with a different Satellite model - the signal was fine on another laptop in the room - the problem was the power management option / power plan - the link below says it all but in short if it is on balanced the default option the default means that it tells the router to go into a power save mode that it might not support.
    http://support.microsoft.com/kb/928152
    Have a read, hope it helps as it worked for me and is a very simple solution!
    Message was edited by: AndreaEoF
    Sorry just realised it was covered in post above, I just expanded on it a little.

  • I recently installed Os Lion and now I keep losing my internet connection...I think it must be the upload...

    I recently installed Os Lion and now keep losing my internet connection, numerous times a day.  Before the upgrade, I never had a connectivity issue.  Can you advise me how to correct this problem?

    The answer may be found in the More Like This column.  Have you checked there?

  • Why does my ipod keep losing its network connection?

    My ipod keeps losing its network connection every few minutes. Ive tried resetting the network settings, resetting the router and neither worked.  Apart from my SpeedTouch router being knackered any other suggestions please?

    Any chance there is interference in the area?
    Do other devices and computers work? and are they wired or not?

  • LDAP Connection exception: unable to retreive the specified realm(s).

    I am using Embedded OC4J and I have a web form based authentication (j_security _check) and configured my orion-application.xml to use LDAP connection in this way:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <orion-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-application-10_0.xsd">
    <jazn provider="LDAP" location="ldap://192.168.1.114:389"
    default-realm="cn" jaas-mode="doAsPrivileged"/>
    <jazn-loginconfig>
    <application>
    <name>ceads</name>
    <login-modules>
    <login-module>
    <class>oracle.security.jazn.login.module.LDAPLoginModule</class>
    <control-flag>required</control-flag>
    <options>
    <option>
    <name>oracle.security.jaas.ldap.connect.pool.prefsize</name>
    <value>10</value>
    </option>
    ....... other LDAp parameters ...
    When I try to log in, is always failed and I get this exception. I have no Idea what to do.
    javax.security.auth.login.LoginException: oracle.security.jazn.JAZNException: The system is unable to retreive the specified realm(s).
    at oracle.security.jazn.spi.ldap.LDAPRealmManager.searchRealms(LDAPRealmManager.java:1194)
    at oracle.security.jazn.spi.ldap.LDAPRealmManager.getRealm(LDAPRealmManager.java:238)
    at oracle.security.jazn.login.module.RealmLoginModule.getRealmFromUsername(RealmLoginModule.java:247)
    at oracle.security.jazn.login.module.RealmLoginModule.getRealm(RealmLoginModule.java:219)
    at oracle.security.jazn.login.module.RealmLoginModule.getRealmUser(RealmLoginModule.java:198)
    at oracle.security.jazn.login.module.RealmLoginModule.authenticate(RealmLoginModule.java:111)
    at oracle.security.jazn.login.module.RealmLoginModule.authenticate(RealmLoginModule.java:86)
    at oracle.security.jazn.login.module.AbstractLoginModule.login(AbstractLoginModule.java:265)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
    at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
    at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
    at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
    at oracle.security.jazn.oc4j.OC4JUtil.doJAASLogin(OC4JUtil.java:241)
    at oracle.security.jazn.oc4j.GenericUser$1.run(JAZNUserManager.java:818)
    at oracle.security.jazn.oc4j.OC4JUtil.doWithJAZNClsLdr(OC4JUtil.java:173)
    at oracle.security.jazn.oc4j.GenericUser.authenticate(JAZNUserManager.java:814)
    at oracle.security.jazn.oc4j.FilterUser.authenticate(JAZNUserManager.java:1143)
    at com.evermind.server.http.EvermindHttpServletRequest.checkAndSetRemoteUser(EvermindHttpServletRequest.java:3760)
    at com.evermind.server.http.EvermindHttpServletRequest.getUserPrincipalInternal(EvermindHttpServletRequest.java:3727)
    at com.evermind.server.http.HttpApplication.checkAuthenticationAndAuthorize(HttpApplication.java:6350)
    at com.evermind.server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:3030)
    at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:738)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
    at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
    at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:234)
    at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:29)
    at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:879)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.IllegalStateException: LDAP properties not properly defined. Please check your JAZN configuration.
    at oracle.security.jazn.spi.ldap.LDAPContext.getDirContext(LDAPContext.java:476)
    at oracle.security.jazn.spi.ldap.LDAPContext.getDefaultDirContext(LDAPContext.java:246)
    at oracle.security.jazn.spi.ldap.LDAPContext.getOrclRootCtxDN(LDAPContext.java:187)
    at oracle.security.jazn.spi.ldap.LDAPContext.getSiteJAZNCtxDN(LDAPContext.java:222)
    at oracle.security.jazn.spi.ldap.LDAPRealmManager.searchRealms(LDAPRealmManager.java:1087)
    ... 37 more
    Edited by: user6112181 on 15-oct-2010 19:30
    Edited by: user6112181 on 15-oct-2010 19:31

    Hi,
    Can you access the URL using a browser? Does it work with the credentials used for the RunAs account?
    Strange error message though - are the account you are running the console with, present in the SCSM CMDB?
    Regards
    //Anders
    Anders Asp | Lumagate | www.lumagate.com | Sweden | My blog: www.scsm.se

  • LDAP Connection - users in more than one group

    Hallo.
    I set up an appl. with ldap connection (Novell eDirectory 8 / Novell 6.5).
    Working fine for users in an specified container.
    Using (Based on a pre-configured scheme from the gallery
    ; Show Login Page and Use LDAP Directory Credentials)
    LDAP DN STRING=
    cn=%LDAP_USER%,o=los
    only users in container los can connect,
    Using
    LDAPDN=
    cn=%LDAP_USER%,ou=amt10,o=los
    now menbers of amt10 can connect but no one else
    Is there an hint to get it work recursive ? (like mod_auth_ldap in apache does ?) So all users in any conainer under o=los will able to connect
    I have nearly 1000 Users in ~50 Containers, what sould I do best? What is misconfigured?
    Ralf

    I'm using a nifty little application call iCalPublish. Check it out at http://www.buddy.com/ical/
    sb

Maybe you are looking for