Glassfish Web Service Application Encounters Certification Path Error

The requested target had no valid certification path, leading to errors in the PKIX validation process, as seen in the code of PKIXValidator and Validator. This caused issues during the invocation of all tests in JUnitPlatformProvider, which was invoked by the ForkedBooter class.


My Java application effectively generates user accounts on a Windows DC through ldaps by importing the self-signed certificate from the Windows server to my local keystore.

I have developed a web service that operates on Glassfish 4.0 and employs identical code to generate user accounts.

The issue at hand is that the web service is currently presenting an error that was previously encountered and resolved through the importation of the certificate to the 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.(
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.(
at engine.CreateStudent.(
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$

An SSLHandshakeException was caused by a ValidatorException, specifically, a PKIX path building failure. This occurred because a valid certification path could not be found for the requested target. As a result, Alerts.getSSLException() threw an exception, and the SSLSocketImpl and Handshaker classes also encountered fatal errors. The ClientHandshaker class was unable to process the server’s certificate message, and the SSLSocketImpl was unable to read the record. In addition, there were issues with the AppOutputStream, BufferedOutputStream, and Connection classes.

The error occurred at line 359 in where ldapBind() method is invoked, followed by authentication at line 214 in the same class. The exception was caused by ValidatorException from the package, indicating that PKIX path building failed due to SunCertPathBuilderException. The exception occurred at line 387 in where doBuild() method is called, followed by engineValidate() at line 292. The Validator interface’s validate() method was called at line 260, and the X509TrustManagerImpl’s validate() method was called at line 324. The checkTrusted() method was called at line 229, and the checkServerTrusted() method was called at line 124. The ClientHandshaker class’s serverCertificate() method was called at line 1351. The cause of the exception was SunCertPathBuilderException, which occurred at line 145 in, followed by engineBuild() at line 131. The CertPathBuilder’s build() method was called at line 280 in

Despite importing the certificate to both cacerts.jks and keystore.jks located in the C:Program Filesglassfish-4.0glassfishdomainsdomain1config folder, it did not work.

In an attempt to resolve the issue, I experimented with defining the keystore location in my code utilizing the “System.setProperty” method. Specifically, I set the value for ”
” to “C:Program FilesJavajdk1.8.0_05jrelibsecuritycacerts” and also specified the trust store password as “changeit” using the “” property.

Still no joy

Is there anything significant that I’ve overlooked? Additionally, I have installed both the 32-bit and 64-bit versions of JDK on my Windows 8 computer.

Solution 1:

The cause of my application’s inability to detect my certificates was due to the necessary configuration in GlassFish that I had overlooked.

To enable secure communication through the SMTPS transport protocol, the keystore and truststore of the GlassFish Server domain can be accessed by configuring it with the master password of the server.

  1. Access the GlassFish Server Administration Console by typing in the URL
    in a web browser.
  2. Firstly, expand the Configurations tab, followed by the server-config tab. Finally, select
    JVM Settings
  3. To set the keystore master password in the JVM Options tab, simply add the option Replace
    with the desired password, keeping in mind that the default master password is changeit. This applies to the async Example Application and the use of synchronous method invocation in Session Beans 36-5.
  4. To add a JVM option, input ‘’ and substitute ‘master-password’ with the truststore master password. By default, the master password is ‘changeit’.
  5. Save your changes and select the
    restart glassfish
    Server option.

Solution 2:

It appears that the
glassfish container
relies on a specific version and has replaced your default JDK Keystore file with its own path. If the other Java applications on your machine are functioning properly, it seems that the issue is specific to Glassfish. You may want to try the following solution.

System.clearProperty(""); //add in servlet init()

Upon servlet startup, it is recommended to execute a one-time operation that replaces the Keystore of glassfish with the system default Keystore to ensure optimal functionality.

If the startup servlet class lacks an init, include this in it.

public void init() throws ServletException

To set this property for your JDK, a different approach is required. This is because the code should be executed in two different environments: one without containers (compile and run), and the other within a servlet in your web application (printing the result on a sample webpage instead of using system println).


The presence or absence of glassfish significantly affects the outcome. Specifically, when glassfish is present, the result is as follows:


Result without glassfish:


Nullifying it resolves all the issues.

Frequently Asked Questions