How to resolve the PKIX path building failed

When you first setup Maven in your office/home computer you might come up with an exception as below when you try to run/build the Maven project.

Could not transfer artifact com.adobe.aem:aem-api:pom: from/to adobe-public-releases ( PKIX path building failed: unable to find valid certification path to requested target -> [Help 1]

SOLUTION to PKIX path building failed

So for the exception above we can see that the URL is clearly mentioned in the exception report. In this case it is

Resolution Steps:

STEP 1:  Navigate to the URL in the exception report using a browser. In this case I am using Google Chrome browser. See below snapshot.

STEP 2: Now press F12 or right click on the page and click on “Inspect”. This will open the developer tools.

STEP 3: Go to the “Security” tab.

STEP 4: Click on the “View Certificate” button.

STEP 5: Check the name of the Certificate (or the issuing authority)

STEP 6: Now close this window and go to browser “Settings”.

STEP 7: Now search for “Manage Certificates”. Alternatively, you can open the “Internet Options” in IE or similar browser and go to “Content” tab and click on “Certificates” button.

STEP 8: Now find the name of the certificate matching the one in STEP 5.

STEP 9: Click on “Export” and export it in a new file (using the default selected format).

STEP 10: Now run the JAVA  Keytool command to add this certificate to your computer’s JDK keystore.

STEP 11: You should run this command.

keytool -import -alias ctsrootca3 -file D:\certs\ctsrootca3.cer -keystore "C:\Program Files\Java\jdk1.8.0_152\jre\lib\security\cacerts"

Please make changes as below.
D:\certs\ctsrootca3.cer  - This should be the path to your certificate file that you exported.
C:\Program Files\Java\jdk1.8.0_152 – This should be path to your JDK folder.
If prompted for a password use : “changeit” (without the quotes, this is the default password for cacerts file)

STEP 12: After successful addition of the key you will see a message like this.

STEP 13: If you have followed this steps correctly then now when you run Maven it should not give any errors.

How to resolve ObjectFactory Collisions in JAVA

In my previous article I have explained how to generate the web service classes.If you have not already read the topic then I would advise you to do so. Moving on, we can sometimes get an error like below

[ERROR] Two declarations cause a collision in the ObjectFactory cl
  line 1191 of file:/D:/RAMEEZ/Web%20Services/TeamBpl/TeamBpl3.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 981 of file:/D:/RAMEEZ/Web%20Services/TeamBpl/TeamBpl3.xsd

This is a very common issue we face, and the way to resolve this is to simply write a XML file having a JAXB binding configuration.

Simple Steps for Clear Understanding:

Here are a few simple steps with images to help you fix the issue quickly :)


Analyze the issue.
From the above error log we see line number 1191 and 981 have issues in the
XSD Schema file. Lets look into the XSD file. See below.


So this is happening because the "name" attribute is somehow causing collision when the WSDL file is getting parsed.


To solve this simple open a new file in Notepad(or any text editor you use) and name it something like "conflict.xml".


Copy it from here.

<jxb:bindings version="1.0" xmlns:jxb="" xmlns:xs="">

 <jxb:bindings node="/xs:schema" schemalocation="TeamBpl3.xsd">
  <jxb:bindings schemalocation="TeamBpl3.xsd">
   <jxb:bindings node="./xs:element[@name='MediaUrl']">
    <jxb:factorymethod name="RootMediaElement">



Now run the "wsimport" command with the -b switch. This is called the binding (-b).

wsimport [WSDL_FILE.wsdl] -b conflict.xml -keep -verbose


This will generate the stub classes properly without any issues.


When you have multiple collisions then in that case you have to write multiple jxb:bindings for each. Means you have to repeat line number 5 to 11 from STEP 3.

Hope this helps!

Steps to Create Web Service Stub

This document gives instructions on creating web service stubs better knowas proxy classes. We will take an example and proceed with the explanation.


Copy the URL link in the browser address bar and hit enter.Check if the WSDL is accessible through your network or not.


Download the WSDL file in a folder and should be saved with the ".wsdl" extension.


Now start to download the artifacts in a folder in your local drive.This should include the WSDL file and all the associated XSDs. The XSD files can be downloaded from the links found inside the downloaded WSDL file.


Go into the WSDL file.You will see a section having the schemas.


Rename the XSD Http links.Point it to the local path of the XML Schemas.


Open a command prompt and check the "wsimport" tool.


We will use the wsimport and the associated commands to create the stubs.Please check the snap shot below f the command prompt.The command is like:wsimport -keep -extensionThere are many associated commands. We need to use them as and when required.


After the previous command we can see folders created in the same destination of the artifact files.


Copy this folders in the “src” folder of your JAVA project in your IDE.It should look like this ad you are good to go.


Java DecimalFormat - For Large Decimal Point Numbers

The Java DecimalFormat class helps us to format numbers in many ways. I was trying to convert
a big number to a 2 decimal point number.Thought of sharing the same with some explaination.

Trying to achieve this:    1,308,207 ---> 1.31

    String number = "1,308,207";
    java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
    number = number.replace(",", ""); 
    Float f = Float.parseFloat(number) / 1000000;
    String result = df.format(f); 
    System.out.println(result);   // result = 1.31

So how does it work??

Well it works like this. DecimalFromat uses java.math.RoundingMode.HALF_EVEN method which
rounds off the number to nearest even i.e when it's 0.05 it becomes 0.1.

1. The number becomes 1308207 at line 3.
2. At line no. 5 it becomes 1.308207.
3. Now the actual formatting starts:-
4. The right hand side(RHS) value is 07,so nearest round off is 10, only 1 taken & RHS discarded.
5. Now the number becomes 1.308201
6. Rightmost 01,the nearest round off id 00, RHS discarded & number becomes 0.
7. Again number becomes smaller 1.30820, in same way becomes 1.3082.
8. Next step : 1.308
9. Finally 1.31(08 becomes 10 with HALF_EVEN method and 0 discarded).

Do you have suggestions or want to improve the solution? Please do feel free to write back to us