glassfish
  1. glassfish
  2. GLASSFISH-15447

External resource permamenly fails on connection error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0
    • Component/s: jca
    • Labels:
      None
    • Environment:

      Build 35

      Description

      When connection to external LDAP will be closed in any reason, then only server restart allows to reconnect to it.
      Index: JndiProxyObjectFactory.java
      — JndiProxyObjectFactory.java Base (BASE)
      +++ JndiProxyObjectFactory.java Locally Modified (Based On LOCAL)
      @@ -46,6 +46,7 @@

      import java.util.Enumeration;
      import java.util.Hashtable;
      +import javax.naming.CommunicationException;
      import javax.naming.Context;
      import javax.naming.Name;
      import javax.naming.NamingException;
      @@ -60,7 +61,6 @@

      • A proxy object factory for an external JNDI factory
        */
        public class JndiProxyObjectFactory implements ObjectFactory {
        -
        // for every external-jndi-resource there is an InitialContext
        // created from the factory and environment properties
        private static Hashtable<ResourceInfo, Context> contextMap = new Hashtable<ResourceInfo, Context>();
        @@ -161,7 +161,24 @@

      // use the name to lookup in the external JNDI naming context
      try {
      + try

      { return context.lookup(jndiLookupName); + }

      catch(CommunicationException ce) {
      + //Silently skip, we can show warning here
      + synchronized(contextMap) {
      + Object result;
      + try

      { + //On "stack" can be old context + context = contextMap.get(resourceInfo); + result = context.lookup(jndiLookupName); + }

      catch(CommunicationException recreateContext)

      { + context = loadInitialContext(jndiFactoryClass, env); + result = context.lookup(jndiLookupName); + contextMap.put(resourceInfo, context); + return result; + }

      + }
      + }
      } catch (NameNotFoundException e)

      { throw new ExternalNameNotFoundException(e); }

        Activity

        Hide
        naman_mehta added a comment -

        ------------------------------------------------------------------------
        r59628 | naman_mehta | 2013-02-19 13:46:29 +0530 (Tue, 19 Feb 2013) | 4 lines
        Changed paths:
        M /trunk/main/appserver/resources/resources-connector/src/main/java/org/glassfish/resources/naming/JndiProxyObjectFactory.java

        Fixing issue: http://java.net/jira/browse/GLASSFISH-15447
        External jndi resource fails when ldap resource goes down and come back again.

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

        Show
        naman_mehta added a comment - ------------------------------------------------------------------------ r59628 | naman_mehta | 2013-02-19 13:46:29 +0530 (Tue, 19 Feb 2013) | 4 lines Changed paths: M /trunk/main/appserver/resources/resources-connector/src/main/java/org/glassfish/resources/naming/JndiProxyObjectFactory.java Fixing issue: http://java.net/jira/browse/GLASSFISH-15447 External jndi resource fails when ldap resource goes down and come back again. ------------------------------------------------------------------------
        Hide
        naman_mehta added a comment -

        Fixed the issue.

        Added code to do re-lookup when it comes back.

        Show
        naman_mehta added a comment - Fixed the issue. Added code to do re-lookup when it comes back.
        Hide
        c_krebs added a comment - - edited

        We're having the same issue. We're using an external JNDI resource with several hosts in the provider list, such that next LDAP server can take over, if one fails:

        asadmin create-jndi-resource --jndilookupname ou=People --restype=javax.naming.DirContext \
        --factoryclass=com.sun.jndi.ldap.LdapCtxFactory \
        --property java.naming.provider.url="ldap\://ldap-1\:1389 ldap\://ldap-2\:1389"
        ldap/user
        

        However, when the first LDAP server is down we're getting these javax.naming.CommunicationException. Only restarting the glassfish instance helps.

        Show
        c_krebs added a comment - - edited We're having the same issue. We're using an external JNDI resource with several hosts in the provider list, such that next LDAP server can take over, if one fails: asadmin create-jndi-resource --jndilookupname ou=People --restype=javax.naming.DirContext \ --factoryclass=com.sun.jndi.ldap.LdapCtxFactory \ --property java.naming.provider.url= "ldap\: //ldap-1\:1389 ldap\://ldap-2\:1389" ldap/user However, when the first LDAP server is down we're getting these javax.naming.CommunicationException . Only restarting the glassfish instance helps.
        Hide
        t_tretau added a comment -

        Looks like this is the same problem. I use an external jndi resource and after some time the connection hangs. Only restart works..

        [#|2011-10-24T11:05:44.091+0200|SEVERE|glassfish3.1.1|com.xxx.spnego.IntranetSpnegoServerAuthModule|_ThreadID=22;_ThreadName=Thread-2;|Error accessing ldap directory.
        javax.naming.NamingException: Lookup failed for 'ADLDAP' in SerialContext[myEnv=

        {java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.s un.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}

        [Root exception is javax.naming.CommunicationException: Connection reset [Root exception is java.n
        et.SocketException: Connection reset]; remaining name 'DC=hsdg-ad,DC=int']
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.xxx.spnego.IntranetSpnegoServerAuthModule.getGroupsForCaller(IntranetSpnegoServerAuthModule.java:46)
        at net.java.spnego.SpnegoServerAuthModule.setCallerPrincipal(SpnegoServerAuthModule.java:458)
        at net.java.spnego.SpnegoServerAuthModule.validateRequest(SpnegoServerAuthModule.java:284)
        at com.sun.enterprise.security.jmac.config.GFServerConfigProvider$GFServerAuthContext.validateRequest(GFServerConfigProvider.java:1171)
        at com.sun.web.security.RealmAdapter.validate(RealmAdapter.java:1445)
        at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1323)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:551)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:623)
        at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:662)
        Caused by: javax.naming.CommunicationException: Connection reset [Root exception is java.net.SocketException: Connection reset]; remaining name 'DC=xxx-ad,DC=int'
        at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1983)
        at com.sun.jndi.ldap.LdapCtx.doSearchOnce(LdapCtx.java:1914)
        at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1008)
        at com.sun.jndi.toolkit.ctx.ComponentContext.p_lookup(ComponentContext.java:526)
        at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:159)
        at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:148)
        at com.sun.enterprise.resource.naming.JndiProxyObjectFactory.getObjectInstance(JndiProxyObjectFactory.java:164)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
        ... 32 more
        Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        at com.sun.jndi.ldap.Connection.run(Connection.java:820)
        ... 1 more

        #]
        Show
        t_tretau added a comment - Looks like this is the same problem. I use an external jndi resource and after some time the connection hangs. Only restart works.. [#|2011-10-24T11:05:44.091+0200|SEVERE|glassfish3.1.1|com.xxx.spnego.IntranetSpnegoServerAuthModule|_ThreadID=22;_ThreadName=Thread-2;|Error accessing ldap directory. javax.naming.NamingException: Lookup failed for 'ADLDAP' in SerialContext[myEnv= {java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.s un.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.CommunicationException: Connection reset [Root exception is java.n et.SocketException: Connection reset]; remaining name 'DC=hsdg-ad,DC=int'] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) at javax.naming.InitialContext.lookup(InitialContext.java:392) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.xxx.spnego.IntranetSpnegoServerAuthModule.getGroupsForCaller(IntranetSpnegoServerAuthModule.java:46) at net.java.spnego.SpnegoServerAuthModule.setCallerPrincipal(SpnegoServerAuthModule.java:458) at net.java.spnego.SpnegoServerAuthModule.validateRequest(SpnegoServerAuthModule.java:284) at com.sun.enterprise.security.jmac.config.GFServerConfigProvider$GFServerAuthContext.validateRequest(GFServerConfigProvider.java:1171) at com.sun.web.security.RealmAdapter.validate(RealmAdapter.java:1445) at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1323) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:551) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:623) at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:662) Caused by: javax.naming.CommunicationException: Connection reset [Root exception is java.net.SocketException: Connection reset] ; remaining name 'DC=xxx-ad,DC=int' at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1983) at com.sun.jndi.ldap.LdapCtx.doSearchOnce(LdapCtx.java:1914) at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1008) at com.sun.jndi.toolkit.ctx.ComponentContext.p_lookup(ComponentContext.java:526) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:159) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:148) at com.sun.enterprise.resource.naming.JndiProxyObjectFactory.getObjectInstance(JndiProxyObjectFactory.java:164) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514) ... 32 more Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:168) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) at com.sun.jndi.ldap.Connection.run(Connection.java:820) ... 1 more #]
        Hide
        Cheng Fang added a comment -

        assign to connector team for evaluation.

        Show
        Cheng Fang added a comment - assign to connector team for evaluation.
        Hide
        scatari added a comment -

        To be considered for the next release, but this is not a common use case.

        Show
        scatari added a comment - To be considered for the next release, but this is not a common use case.
        Hide
        rsmogura added a comment -

        This is bettered version

        Show
        rsmogura added a comment - This is bettered version

          People

          • Assignee:
            naman_mehta
            Reporter:
            rsmogura
          • Votes:
            4 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: