Issue
I added my CER file to my keystore by issuing the following command:
"keytool -import -storepass [insert store pass] -noprompt -alias [insert alias] -keystore "[insert directory]\Java\jre1.8.0_45\lib\security\cacerts" -trustcacerts -file [insertname].cer"
I am trying to make a REST call in a Java application. My REST call works when I run the application in Eclipse but when I run the same application in NetBeans, I get the following error message which implies I did not add the CER file to the keystore:
"PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
I copied the application from NetBeans to Eclipse directly to narrow down the issue and it worked perfectly fine in Eclipse so I figure it's not a coding problem but a configuration problem somewhere in NetBeans. Anyone have any idea how I can fix this? How come the application works in Eclipse but not in NetBeans? I've been trying to look around but cannot find anything.
If it's also helpful, I am using a Maven Java Application project.
FYI: I am using NetBeans IDE 8.2 Patch 2.
Solution
You need to make sure your application run from NetBeans is using the same JDK.
Check the JDK referenced in the libraries of your project.
Or make sure NEtbeans itself is started using the right JDK.
The OP dunce1 confirms in the comments it was not the case:
Looks like NetBeans was using the JRE environment in JDK where as Eclipse was using non-JDK JRE environment for runtime
Answered By - VonC