0

I am trying to use LDAP authentication using JNDIRealm instead of tomcat-users.xml. But I'm getting the below error.

Can anyone say in which scenarios this exception occurs? Can wrong "connectionPassword" in JNDIRealm of server.xml file cause this error?

    INFO: Starting Servlet Engine: Apache Tomcat/7.0.92
    Jul 23, 2019 10:25:19 AM org.apache.catalina.realm.JNDIRealm open
    INFO: Exception performing authentication. Retrying...
    javax.naming.CommunicationException: **.com:389 [Root exception is java.net.SocketTimeoutException: connect timed out]
        at com.sun.jndi.ldap.Connection.<init>(Connection.java:228)
        at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:137)
        at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1609)
        at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2749)
        at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:319)
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192)
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210)
        at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153)
        at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
        at javax.naming.InitialContext.init(InitialContext.java:244)
        at javax.naming.InitialContext.<init>(InitialContext.java:216)
        at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:101)
        at org.apache.catalina.realm.JNDIRealm.createDirContext(JNDIRealm.java:2477)
        at org.apache.catalina.realm.JNDIRealm.open(JNDIRealm.java:2449)
        at org.apache.catalina.realm.JNDIRealm.startInternal(JNDIRealm.java:2669)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1227)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:444)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:758)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:710)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)
    Caused by: java.net.SocketTimeoutException: connect timed out
        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.sun.jndi.ldap.Connection.createSocket(Connection.java:362)
        at com.sun.jndi.ldap.Connection.<init>(Connection.java:215)
        ... 31 more
Reegan Miranda
  • 2,879
  • 6
  • 43
  • 55
Rose
  • 21
  • 1
  • 7
  • is your **.com:389 accessible if you try a telnet ? – Eugène Adell Jul 23 '19 at 20:50
  • I checked by opening command prompt and typing the command "telnet ldap://domain.com 389" It shows "Connecting To ldap://domain.com...Could not open connection to the host, on port 389: Connect failed" Is this the right way to check? – Rose Jul 24 '19 at 04:35
  • no, your command should be `telnet domain.com 389` – Eugène Adell Jul 24 '19 at 06:59
  • I entered "telnet domain.com 389" and I'm getting "Connecting To domain.com...Could not open connection to the host, on port 389: Connect failed" – Rose Jul 24 '19 at 09:35
  • If you can't connect with a telnet, your Tomcat also cannot connect. Is there a firewall between them ? – Eugène Adell Jul 24 '19 at 19:57

0 Answers0