?
Solved

Socket closed exception

Posted on 2010-03-30
6
Medium Priority
?
4,181 Views
Last Modified: 2013-12-19
Hi Experts,

I have a web application with 2 war apps. I use the same code in both war application to get the initial context (code below). It works just fine with same credentials in the first app but throws the following exception in the second app.

app is deployed on websphere  application server 6.1


[3/30/10 14:31:23:481 EDT] 00000020 SystemErr     R javax.naming.ServiceUnavailableException: 192.168.1.65:636; socket closed
[3/30/10 14:31:23:481 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.Connection.readReply(Connection.java:439)
[3/30/10 14:31:23:482 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:355)
[3/30/10 14:31:23:482 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:207)
[3/30/10 14:31:23:482 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2652)
[3/30/10 14:31:23:482 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:298)
[3/30/10 14:31:23:482 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:190)
[3/30/10 14:31:23:482 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:208)
[3/30/10 14:31:23:482 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:151)
[3/30/10 14:31:23:483 EDT] 00000020 SystemErr     R       at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:81)
[3/30/10 14:31:23:483 EDT] 00000020 SystemErr     R       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:679)
[3/30/10 14:31:23:483 EDT] 00000020 SystemErr     R       at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:259)
[3/30/10 14:31:23:483 EDT] 00000020 SystemErr     R       at javax.naming.InitialContext.init(InitialContext.java:235)
[3/30/10 14:31:23:483 EDT] 00000020 SystemErr     R       at javax.naming.InitialContext.<init>(InitialContext.java:209)
[3/30/10 14:31:23:484 EDT] 00000020 SystemErr     R       at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:93)
[3/30/10 14:31:23:484 EDT] 00000020 SystemErr     R       at com.bci.ldap.LDAPManager.getInitialContext(LDAPManager.java:63)
[3/30/10 14:31:23:484 EDT] 00000020 SystemErr     R       at com.bci.ldap.LDAPManager.<init>(LDAPManager.java:29)
[3/30/10 14:31:23:484 EDT] 00000020 SystemErr     R       at com.bci.ldap.services.LDAPEmployee.changePassword(LDAPEmployee.java:15)
[3/30/10 14:31:23:484 EDT] 00000020 SystemErr     R       at com.bci.servlet.ChangePassword.doPost(ChangePassword.java:44)
[3/30/10 14:31:23:484 EDT] 00000020 SystemErr     R       at com.bci.servlet.ChangePassword.doGet(ChangePassword.java:27)
[3/30/10 14:31:23:484 EDT] 00000020 SystemErr     R       at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
[3/30/10 14:31:23:485 EDT] 00000020 SystemErr     R       at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[3/30/10 14:31:23:485 EDT] 00000020 SystemErr     R       at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1095)
[3/30/10 14:31:23:485 EDT] 00000020 SystemErr     R       at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:569)
[3/30/10 14:31:23:485 EDT] 00000020 SystemErr     R       at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[3/30/10 14:31:23:485 EDT] 00000020 SystemErr     R       at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3440)
[3/30/10 14:31:23:485 EDT] 00000020 SystemErr     R       at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
[3/30/10 14:31:23:486 EDT] 00000020 SystemErr     R       at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
[3/30/10 14:31:23:486 EDT] 00000020 SystemErr     R       at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1461)
[3/30/10 14:31:23:486 EDT] 00000020 SystemErr     R       at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:118)
[3/30/10 14:31:23:486 EDT] 00000020 SystemErr     R       at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
[3/30/10 14:31:23:486 EDT] 00000020 SystemErr     R       at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
[3/30/10 14:31:23:486 EDT] 00000020 SystemErr     R       at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
[3/30/10 14:31:23:487 EDT] 00000020 SystemErr     R       at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[3/30/10 14:31:23:487 EDT] 00000020 SystemErr     R       at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[3/30/10 14:31:23:487 EDT] 00000020 SystemErr     R       at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
[3/30/10 14:31:23:487 EDT] 00000020 SystemErr     R       at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[3/30/10 14:31:23:487 EDT] 00000020 SystemErr     R       at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[3/30/10 14:31:23:487 EDT] 00000020 SystemErr     R       at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[3/30/10 14:31:23:487 EDT] 00000020 SystemErr     R       at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
[3/30/10 14:31:23:488 EDT] 00000020 SystemErr     R       at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
[3/30/10 14:31:23:488 EDT] 00000020 SystemErr     R       at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
[3/30/10 14:31:23:488 EDT] 00000020 SystemErr     R       at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
private DirContext getInitialContext(
      String protocol, 
      String hostname, 
      int port,
      String username, 
      String password, 
      String keystore)
                throws NamingException {

                String providerURL =
                    new StringBuffer("")
                                .append(protocol)
                                .append("://")
                        .append(hostname)
                        .append(":")
                        .append(port)
                        .toString();
                
                System.setProperty("javax.net.ssl.keyStore", keystore); 

                Properties props = new Properties();
                props.put(Context.INITIAL_CONTEXT_FACTORY,
                          "com.sun.jndi.ldap.LdapCtxFactory");
                props.put(Context.PROVIDER_URL, providerURL);

                if ((username != null) && (!username.equals(""))) {
                    props.put(Context.SECURITY_AUTHENTICATION, "simple");
                    props.put(Context.SECURITY_PRINCIPAL, username);
                    props.put(Context.REFERRAL, "ignore");
                    if(SSLEnabled.equalsIgnoreCase("1"))
                        props.put(Context.SECURITY_PROTOCOL, "SSL");
                    props.put(Context.SECURITY_CREDENTIALS,
                        ((password == null) ? "" : password));
                }

                return new InitialDirContext(props);
            }

Open in new window

0
Comment
Question by:bcisystems
  • 2
  • 2
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Venabili
ID: 29144434
Does it happen only when both run at the same time or even if the first one is not doing anything and only the second one is running? Is it always the same the one that is failing? Had you try redeploying the war (thinking here that maybe you are not running the same code exactly?)? Do you call the method with the same parameters?
0
 

Author Comment

by:bcisystems
ID: 29204420
No they are not running the same time. First one runs fine. And second one throws this. After that first one fails as well. Second on always fails.

Thanks
S
0
 
LVL 20

Expert Comment

by:Venabili
ID: 29206811
Sounds like a restriction of the number of connections between the servers. Let me think where this might have happened....  It is definitely not a code issue
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:bcisystems
ID: 31748332
I havent had any new improvements on this. Admin can close the questions and retrun the points.
0
 
LVL 8

Accepted Solution

by:
AdminRAM earned 2000 total points
ID: 32796514
Do you have any load balancer infornt of LDAP server ? if so check the following information

------------------------------------------------------

load balancer for LDAP failover then you need to make sure follow the given below setup.

If they want to use reuse connection on WAS then they need to Enabled Session Affinity on load balancer
If they want disable Session Affinity on load balancer then they must disable reuse connection on WAS

This is working as design.. Disable the Reuse Connection field only if you use routers to send requests to multiple LDAP servers, and if the routers do not support affinity. Leave this field enabled for all other situations.


-------------------------------------------------------------------------------------------------

Reuse  connection

    Specifies whether the server reuses the Lightweight Directory Access Protocol (LDAP) connection. Clear this option only in rare situations where a router is used to distribute requests to multiple LDAP servers and when the router does not support affinity.

    Default:       Enabled
    Range:       Enabled or Disabled

    Important: Disabling the Reuse connection option causes WebSphere Application Server to create a new LDAP connection for every LDAP search request. This situation impacts system performance if your environment requires extensive LDAP calls. This option is provided because the router is not sending the request to the same LDAP server. The option is also used when the idle connection timeout value or firewall timeout value between WebSphere Application Server and LDAP is too small.

    If you are using WebSphere Edge Server for LDAP failover, you must enable TCP resets with the Edge server. A TCP reset causes the connection to be immediately closed, and a failover to the backup server. For more information, please see "Sending TCP resets when server is down" at http://www-3.ibm.com/software/webservers/appserv/doc/v50/ec/infocenter/edge/LBguide.htm#HDRRESETSERVER and the Edge Server V2 - TCP Reset feature in PTF #2 described in: ftp://ftp.software.ibm.com/software/websphere/edgeserver/info/doc/v20/en/updates.pdf.
------------------------------------------------------------------------------------------------------------

see disabling reuse connection will help.

0
 
LVL 8

Expert Comment

by:AdminRAM
ID: 33465717
Thank you very much for points. I appreciate it.

Have a good day
AdminRam
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A solution for Fortify Path Manipulation.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
The viewer will learn how to implement Singleton Design Pattern in Java.
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question