SonarQube 7.9.1 docker container, strange LDAP issue

Hi there,

I have a stange problem with the actual sonarqube 7.9.1 docker container (build at 15.08.2019) and the LDAP 2.2 plugin (build 608).

The config looks like:

If I ran the container on Mac everything is OK and SonarQube connects to my LDAP server.
If I ran the same container with the same configuration on Redhat EL7 I get the following Error:

2019.08.22 14:07:15 INFO  web[][org.sonar.INFO] Security realm: LDAP
2019.08.22 14:07:15 INFO  web[][o.s.p.l.LdapSettingsManager] User mapping: LdapUserMapping{baseDn=cn=users,cn=accounts,dc=usermanagement,dc=t00ls,dc=de, request=(&(objectClass=inetorgperson)(uid={0})(|(memberOf=cn=sonarqube-software-users,cn=groups,cn=accounts,dc=usermanagement,dc=t00ls,dc=de)(memberOf=cn=sonarqube-administrators,cn=groups,cn=accounts,dc=usermanagement,dc=t00ls,dc=de))), realNameAttribute=cn, emailAttribute=mail}
2019.08.22 14:07:15 INFO  web[][o.s.p.l.LdapSettingsManager] Group mapping: LdapGroupMapping{baseDn=cn=groups,cn=accounts,dc=usermanagement,dc=t00ls,dc=de, idAttribute=cn, requiredUserAttributes=[dn], request=(&(objectClass=groupOfNames)(member={0}))}
2019.08.22 14:07:15 INFO  web[][o.s.p.l.LdapContextFactory] Test LDAP connection: FAIL
2019.08.22 14:07:15 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
org.sonar.api.utils.SonarException: Security realm fails to start: Unable to open LDAP connection
	at org.sonar.server.user.SecurityRealmFactory.start(
	at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(
	at org.picocontainer.behaviors.AbstractBehavior.start(
	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(
	at org.picocontainer.behaviors.Stored.start(
	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(
	at org.picocontainer.DefaultPicoContainer.startAdapters(
	at org.picocontainer.DefaultPicoContainer.start(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.server.platform.platformlevel.PlatformLevel.start(
	at org.sonar.server.platform.platformlevel.PlatformLevel4.start(
	at org.sonar.server.platform.Platform.start(
	at org.sonar.server.platform.Platform.startLevel34Containers(
	at org.sonar.server.platform.Platform.access$500(
	at org.sonar.server.platform.Platform$1.lambda$doRun$0(
	at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(
	at org.sonar.server.platform.Platform$1.doRun(
	at org.sonar.server.platform.Platform$
	at java.base/ Source)
Caused by: org.sonar.plugins.ldap.LdapException: Unable to open LDAP connection
	at org.sonar.plugins.ldap.LdapContextFactory.testConnection(
	at org.sonar.plugins.ldap.LdapRealm.init(
	at org.sonar.server.user.SecurityRealmFactory.start(
	... 19 common frames omitted
Caused by: javax.naming.CommunicationException: simple bind failed:
	at java.naming/com.sun.jndi.ldap.LdapClient.authenticate(Unknown Source)
	at java.naming/com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
	at java.naming/com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
	at java.naming/javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
	at java.naming/javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
	at java.naming/javax.naming.InitialContext.init(Unknown Source)
	at java.naming/javax.naming.ldap.InitialLdapContext.<init>(Unknown Source)
	at org.sonar.plugins.ldap.LdapContextFactory.createInitialDirContext(
	at org.sonar.plugins.ldap.LdapContextFactory.createBindContext(
	at org.sonar.plugins.ldap.LdapContextFactory.testConnection(
	... 21 common frames omitted
Caused by: Connection or outbound has closed
	at java.base/$AppOutputStream.write(Unknown Source)
	at java.base/ Source)
	at java.base/ Source)
	at java.naming/com.sun.jndi.ldap.Connection.writeRequest(Unknown Source)
	at java.naming/com.sun.jndi.ldap.Connection.writeRequest(Unknown Source)
	at java.naming/com.sun.jndi.ldap.LdapClient.ldapBind(Unknown Source)
	... 35 common frames omitted
2019.08.22 14:07:16 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process
2019.08.22 14:07:17 WARN  web[][o.s.p.ProcessEntryPoint$HardStopperThread] Can not stop in 1000ms
2019.08.22 14:07:17 WARN  web[][o.s.s.a.EmbeddedTomcat] Failed to stop web server
org.apache.catalina.LifecycleException: Failed to stop component [StandardServer[-1]]
	at org.apache.catalina.util.LifecycleBase.stop(
	at org.apache.catalina.startup.Tomcat.stop(
	at org.sonar.process.ProcessEntryPoint$HardStopperThread.lambda$new$0(
	at java.base/java.util.concurrent.Executors$ Source)
	at java.base/ Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$ Source)
	at java.base/ Source)
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardService[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.stop(
	at org.apache.catalina.core.StandardServer.stopInternal(
	at org.apache.catalina.util.LifecycleBase.stop(
	... 9 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.stop(
	at org.apache.catalina.core.StandardService.stopInternal(
	at org.apache.catalina.util.LifecycleBase.stop(
	... 11 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during stop
	at org.apache.catalina.core.ContainerBase.stopInternal(
	at org.apache.catalina.util.LifecycleBase.stop(
	... 13 common frames omitted
2019.08.22 14:07:17 INFO  app[][o.s.a.SchedulerImpl] Process[web] is stopped

To check the LDAP connection, I’ve installed “ldapsearch” in the container and checked the connection:

sonarqube@ef9533682b9d:/opt/sonarqube$ ldapsearch -h -b “dc=usermanagement,dc=t00ls,cn=accounts,dc=de” -x
# extended LDIF
# LDAPv3
# base <dc=usermanagement,dc=t00ls,cn=accounts,dc=de> with scope subtree
# filter: (objectclass=*)
# requesting: ALL

# search result
search: 2
result: 32 No such object

# numResponses: 1

If there would be a connection problem with the command line the output normally looks like:

ldap_sasl_bind(SIMPLE): Can’t contact LDAP server (-1)

The same error occures with:


I have an other container running on Redhat EL7 which connects to my LDAP without any problems.

Has someone an idea how to solve this problem?

Thanks in advanced for any support


Hi @cRaZyT,

Thanks for the detailed report.

I see the following error in your stacktrace:

at java.base/$AppOutputStream.write(Unknown Source)

Which looks like an issue with SSL. I see you’re not running with LDAPS, nor using the LDAPS “usual” port (636), but, I know it is possible to run LDAP on the “regular” port, and still have an SSL handshake take place. Is this the case? If so, can you double check your JDK keystore inside the container (see keytool)?

Hi @Wouter_Admiraal,

I tried using LDAPS which lasts in the same error. Regarding the Port, yes we use the regular port.
Inside the offical sonarqube docker container, the keytool is available but no key is stored over there, which is also the case in the functioning container hosted on Mac OS.

Hi, thanks for the info.

My question was more about how you configured LDAP:

I know it is possible to run LDAP on the “regular” port, and still have an SSL handshake take place. Is this the case?

Sorry if I wasn’t clear: are you “requiring” a SSL/TLS handshake, despite the fact you’re not running on LDAPS/port 636? Are we certain that LDAP is not requesting a SSL handshake (would be weird, but I’m just shooting in the dark here)?

Because it works locally, and you can access from the container using the CLI, only 2 things come to mind:

  1. Your bind credentials are incorrect
  2. IF your LDAP needs a SSL handshake (for whatever strange reason), there could be an issue with the certificates, as your Bash will not necessarily use the same certificates as the JDK.

It’s weird that SonarQube tries to use SSL, but because it works locally, with the exact same setup, I’m leaning towards an issue in the environment rather than with SonarQube itself (for now).

Hi @Wouter_Admiraal,

sorry for my missunderstanding.

  1. The bind credentials are configured in the file which is identical on both docker instances.
  2. No the LDAP server don’t need an SSL handshake.

It’s really weired because there are other docker containers hosted on the RedHat server which are connecting without any issue to the LDAP server.

Hi @Wouter_Admiraal,

I found asolution. I could fix this problem by changing the “ldap.bindDn”.
I’ve changed the string from “ldap.bindDn=id=admin” to “ldap.bindDn=uid=admin”.
I don’t understand why there could be a difference between MAC and RedHat but that solved the problem.


Hi @cRaZyT,

Great! Happy to see you found a solution. I admit I was a bit stumped by your problem :sweat_smile:. I started asking around, but to no avail.

Thank you for sharing it here :+1:!