WSO2 APIM 4.1 OpenSource Pack Build Error- No Compiler Provided


Recently I trie building the wso2 apim product pack using the source code provided by WSO2 on Github Repository and I faced Java Compilation related errors. I'll share my experience about the same. So let's start-

Environment
OS: macOS Ventura
Java: JDK 1.8
WSO2 APIM Source Code: APIM v4.1
Maven: Apache Maven 3.9.4

Problem Statement:
product-apim-4.1.0.zip
2. Go to the root directory product-apim-4.1.0
3. Maven build command failure during mvn clean install

Below is the error snapshot identified during the build process

[INFO] Changes detected - recompiling the module!

[INFO] Compiling 1 source file to /Users/kumargaurav/Downloads/product-apim-4.1.0/modules/styles/product/target/classes

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR : 

[INFO] -------------------------------------------------------------

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

[INFO] 1 error

[INFO] -------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary for WSO2 API Manager - Aggregator Module 4.1.0:

[INFO

[INFO] WSO2 API Manager - Aggregator Module ............... SUCCESS [01:22 min]

[INFO] WSO2 API Manager - Styles Parent ................... SUCCESS [  0.075 s]

[INFO] WSO2 API Manager - Styles .......................... FAILURE [ 49.051 s]

[INFO] WSO2 Stratos  API Manager - UI styles .............. SKIPPED

[INFO] WSO2 API Manager - Multi Tenant Dashboard .......... SKIPPED

[INFO] WSO2 API Manager - Features Parent ................. SKIPPED

[INFO] WSO2 API Manager - Features Aggregator Module ...... SKIPPED

[INFO] extenstions ........................................ SKIPPED

[INFO] org.wso2.am.thirdparty.km .......................... SKIPPED

[INFO] WSO2 API Manager - Integration New Test Module ..... SKIPPED

[INFO] WSO2 API Manager - Based on product backend Test Module SKIPPED

[INFO] WSO2 API Manager - Based on product benchmark Test Module SKIPPED

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time:  03:33 min

[INFO] Finished at: 2023-09-09T22:08:57+05:30

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project org.wso2.am.styles: Compilation failure

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

[ERROR

[ERROR] -> [Help 1]

[ERROR

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

[ERROR

[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <args> -rf :org.wso2.am.styles

kumargaurav@Kumars-MacBook-Pro product-apim-4.1.0 % mvn clean install 


Cause:

I have checked the maven version and found that JAVA is pointed to Plugin JRE only (inside Internet plugins)-


kumargaurav@Kumars-MacBook-Pro ~ % mvn -v

Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9)

Maven home: /Users/kumargaurav/apache-maven-3.9.4

Java version: 1.8.0_301, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

Default locale: en_IN, platform encoding: UTF-8

OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"


So, we have to correct the JDK home to run the maven command properly.


Solution

1. Check the java versions by running the command /usr/libexec/java_home -V


kumargaurav@Kumars-MacBook-Air product-apim-4.1.0 % /usr/libexec/java_home -V

Matching Java Virtual Machines (2):

    1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

    1.8.0_301 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home


It clearly shows two versions (2 JVMs) and now we have to set the JAVA to our JDK directory via user bash profile.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0)


Now, Let's verify the Java Version in maven-


kumargaurav@Kumars-MacBook-Pro product-apim-4.1.0 % mvn -v       

Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9)

Maven home: /Users/kumargaurav/apache-maven-3.9.4

Java version: 1.8.0_301, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home/jre

Default locale: en_IN, platform encoding: UTF-8

OS name: "mac os x", version: "10.16", arch: "x86_64", family: "Mac"


2. Now save the bashprofile and restart the terminal or source the bash profile via source ~/.bashprofile command or sometimes it needs system restart as well.


Run the mvn clean install again and this should succeed now.

Sometimes you might face error connecting to the maven repo; simply re-run the command to overcome this issue.

Please be patient while the pack get's created as it take 30-40 Mins depending upon your internet connection.



Comments

Popular posts from this blog

Oracle SOA Suite- Implementing Email Notification

Oracle SOA Suite 12c- PKIX path building failed & unable to find valid certification path to requested target

Migration of Oracle SOA Suite Composite from 11g to 12c