Hot questions for Using GlassFish in ldap


I'm trying to create a LDAP realm in Glassfish 4.0 (build 89) but every time I tried so far, the following error occurred:

"Invalid property syntax, "=" in value: base-dn=\[...]"

I tried using different browsers and reinstalled Glassfish in Netbeans. The strange thing is that a friend of mine could copy my base-dn and it worked.

Thanks in advance!


This seems to be a bug in Glassfish 4.0. It throws this error if a property contains an equals sign (=). See the following JIRA Issues:

This error doesn't occur in GlassFish 3.x, this may be the reason that it worked when your friend tried it.

Workaround: As a workaround you can just take some value without an equals sign, like e.g. abc and save that. This should successfully create the LDAP realm. Then click on the created realm to edit the property. Now you can replace abc with the desired value (and it can also contains equals signs), save again and you are done.


I have developed an Java application that creates user accounts on a windows DC using ldaps which works fine after importing the self signed certificate from the windows server to my local keystore.

Now i have created a web service running on glassfish 4.0 and using the same code to create the accounts.

The problem is now the web service is now giving me the error below which i initially had but solved it by importing the certificate to my local keystore (cacerts)

Severe:   javax.naming.CommunicationException: simple bind failed: [Root exception is PKIX path building failed: unable to find valid certification path to requested target]
at com.sun.jndi.ldap.LdapClient.authenticate(
at com.sun.jndi.ldap.LdapCtx.connect(
at com.sun.jndi.ldap.LdapCtx.<init>(
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.init(
at javax.naming.ldap.InitialLdapContext.<init>(
at engine.CreateStudent.<init>(
at service.Create.createAccount(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.glassfish.webservices.InstanceResolverImpl$1.invoke(
at org.glassfish.webservices.MonitoringPipe.process(
at org.glassfish.webservices.JAXWSServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.StandardWrapper.service(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardPipeline.doInvoke(
at org.apache.catalina.core.StandardPipeline.invoke(
at com.sun.enterprise.web.WebPipeline.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.doService(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.glassfish.grizzly.http.server.HttpHandler.runService(
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(
at org.glassfish.grizzly.ProcessorExecutor.execute(
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(
at org.glassfish.grizzly.threadpool.AbstractThreadPool$

Caused by: PKIX path building failed: unable to find valid certification path to requested target at at at at at at at at at at at at at at at com.sun.jndi.ldap.Connection.writeRequest( at com.sun.jndi.ldap.Connection.writeRequest( at com.sun.jndi.ldap.LdapClient.ldapBind( at com.sun.jndi.ldap.LdapClient.authenticate( ... 72 more Caused by: PKIX path building failed: unable to find valid certification path to requested target at at at at at a Severe: t at ... 85 more Caused by: unable to find valid certification path to requested target at at at at ... 91 more Info: java.lang.NullPointerException

I have even tried to import the certificate into cacerts.jks and keystore.jks in the C:\Program Files\glassfish-4.0\glassfish\domains\domain1\config folder but to no avail.

I have also tried setting the keystore location in my code using System.setProperty("", "C:\Program Files\Java\jdk1.8.0_05\jre\lib\security\cacerts"); System.setProperty("", "changeit");

Still no joy

Anything 'm missing that is important? By the way i have both x32 and x64 bit of the jdk on my windows 8 machine.


The reason why my application could not see my certificates was because of the setup i was suppose to do in GlassFish.

The GlassFish Server domain needs to be configured with the server's master password to access the keystore and truststore used to initiate secure communications using the SMTPS transport protocol.

  1. Open the GlassFish Server Administration Console in a web browser at http://localhost:4848.
  2. Expand Configurations, then expand server-config, then click JVM Settings.
  3. Click the JVM Options tab, then click Add JVM Option and enter, replacing master-password with the keystore master password. The default master password is changeit. The async Example Application U sing A synchronous Method Invocation in Session Beans 36-5
  4. Click Add JVM Option and enter, replacing master-password with the truststore master password. The default master password is changeit.
  5. Click Save, then restart GlassFish Server.


I´m developping a Web Service. Currently, I´m using Basic Authentication using a file to manage users.

Now I want to use Basic authentication, integrate LDAP server. I installed and I create a LDAP server, using LDAP - Apache Directory Studio.

In Glassfish console I create a new ldapRealm.

My web.xml has this code:


Now I want to specify different roles for different ldap group of users.

How can I achieve this? There is any tutorial for this prupose for Web Services?

There is possiblity to add an annotation specifing roles like @RolesAllowed(LDAP Group) to different methods?


In order to configure the realm in Glassfish look To Create an LDAP Realm in the GlassFish Server.

Regarding Apache Directory Studio, see Let's create an LDAP user and search for him. You may want to see Setting up an LDAP directory server for Alfresco development.


For my application, I need to be able to let users log in via Active Directory. I've configured the LDAP Realm in Glassfish 4, and as long as the users are part of the groups I specify, everything works as it should. But when the user is member of a nested group, Glassfish doesn't map the groups like it should.

I've been looking for this quite some time, and I have found that Glassfish isn't ready for nested groups. Although those statements come from Glassfish V2 and 3.x.

I can't really find a work-around either.



Microsoft specifies a specific search filter for getting nested groups. The filters I found were only for (nested) members of a specific group, not (nested) groups for a specific user. The group-search-filter I needed to use is this one:


I hope anybody looking for the answer to this problem will find this post. For the other Microsoft Active Directory specific filters, click here.