Link to home
Start Free TrialLog in
Avatar of bcisystems
bcisystems

asked on

Socket closed exception

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

Avatar of Venabili
Venabili
Flag of Bulgaria image

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?
Avatar of bcisystems
bcisystems

ASKER

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
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
I havent had any new improvements on this. Admin can close the questions and retrun the points.
ASKER CERTIFIED SOLUTION
Avatar of AdminRAM
AdminRAM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for points. I appreciate it.

Have a good day
AdminRam