Thursday, January 30, 2014

How to resolve WSO2 platform build failures come due to package does not exist

You can follow the steps on building Carbon by the link below :

Following blog post is for the users who have fair knowledge in programming. Intended users will be Quality Assurance Engineers.

How to Isolate :

1. First of all, to isolate the problems you face, it is better to start building according to the modules defined in the pom.xml.


Open the pom.xml in ../platform/branches/turing/product-releases/chunk-07

You will see the modules defined like below.


Build one by one by the following command.

mvn clean install --fail-at-end
fail-at-end will be used to continue the all modules bulding eventhough there is a build failure.

2. Imagine when you are building products you get an error like below.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project sample-utils: Compilation failure: Compilation failure:
[ERROR] /home/ushani/Downloads/Automation_TC/24_Jan_2014/turing/products/bps/3.2.0/modules/samples/product/sample-utils/src/main/java/org/wso2/bps/samples/util/[23,31] package does not exist
[ERROR] /home/ushani/Downloads/Automation_TC/24_Jan_2014/turing/products/bps/3.2.0/modules/samples/product/sample-utils/src/main/java/org/wso2/bps/samples/util/[58,66] package org.bouncycastle.jce.provider does not exist
[ERROR] /home/ushani/Downloads/Automation_TC/24_Jan_2014/turing/products/bps/3.2.0/modules/samples/product/sample-utils/src/main/java/org/wso2/bps/samples/util/[84,35] cannot find symbol
[ERROR] symbol  : variable Base64
[ERROR] location: class org.wso2.bps.samples.util.PasswordEncryptUtil
[ERROR] -> [Help 1]
[ERROR] Failed to execute goal org.wso2.maven:carbon-p2-plugin:1.5.3:p2-repo-gen (3-p2-repo-generation) on project wso2-bps-profile-gen: Error occured when processing the Feature Artifact: org.wso2.bps:org.wso2.bps.samples.utils.feature:3.2.0: ERROR: Failure to find org.wso2.bps:org.wso2.bps.samples.utils.feature:zip:3.2.0 in was cached in the local repository, resolution will not be reattempted until the update interval of wso2-nexus has elapsed or updates are forced

Identify the error, the affected place and the reason :
3. If you look at it properly, you see the error is in class.
4. So the best thing is open the project in idea. from sample-utils/src/main/java/org/wso2/bps/samples onwards.
5. you will see the class name with a red curly underline since there is an error in the class.
6. Go to the class and check what is wrong in it. As per the above error, issue was with the symbol
variable Base64
7. In the code the following line was in red, exposing it as an error.

  String encodedString = Base64.encode(encryptedText);
8. Also there was another curly line in red mentioning the following import hasnt been done correctly.

Solutions :

Solution 1.
a. Either you can check in you .m2 , which is also known as the maven repository in your machine.
.m2 is a repository that is created in every one of your machine, if you have installed maven properly. Whenever you need  any dependencies, it will automatically download in to your maven repository.
You can see your maven repo at the following place :

b. Go to .m2 and follow the import path correctly in the file location.
 You should have a folder called axiom in the following file location.

c. if you don't have a folder that means the issue is because it hasn't been downloaded properly. You can get it from someone else's .m2 repo and replace you one or can check from which location it has been taken. Sometimes axiom folder can be refereed from a different location.
if so you will have to provide the dependency manually in you pom.xml located in the related module.
E.g., I had the issue in sample-utils. So I will refer the pom.xml in that module.

According to this the correct axiom is inside,

path : /home/ushani/.m2/repository/org/apache/ws/commons/axiom

Add the following dependency according to the correct location.


Solution 2:
1. Go near the issue underlined in red colour and get the your curosr top of it and the help comes in the left corner of your code editor window.
It will give you suggestions.

If there is a missing maven dependency it will ask whether to add. You have to click that suggestion and provide the correct path which will come automatically.

By this it will solve the problem and that dependency will be added in to your pom.xml automatically.