0

I’ve been trying to explore WSO2 Microgateway and set up a Microgateway project. Building the project in Windows 10 with the command “micro-gw build project-name” is giving this error: “Could not find or load main class org.wso2.apimgt.gateway.cli.cmd.Main”.

I’ve downloaded the Toolkit and Runtime from https://wso2.com/api-management/api-microgateway/. I've set the Path environment variable to the /bin directory of the Toolkit and Runtime extracted folders, but still the “micro-gw build project-name” command is giving error “Could not find or load main class org.wso2.apimgt.gateway.cli.cmd.Main”. I’ve also cloned the source code from Github (https://github.com/wso2/product-microgateway/) which has the Main.java class and tried setting environment variables to its path. I also tried setting the environment variables to the path where Toolkit batch file is present. I also followed the steps mentioned here, https://github.com/wso2/product-microgateway/#running-the-microgateway. I'm assuming the Toolkit batch file (micro-gw) would execute the Main.java class coming up in the error.

These steps did not resolve the error. I'm new to Java based product, and I'm sure I'm missing something here.

Bee
  • 12,251
  • 11
  • 46
  • 73
Sushant W
  • 1
  • 1
  • This error happens when toolkit initialization has not happened properly. How exactly did you installed the toolkit? Can you follow these steps one more time. 1. Extract the toolkit zip file to a different location 2. Clear the old toolkit location from PATH variable 3. Goto bin directory. 4. Run micro-gw init 5. Check \lib directory. You should see a extracted directory called "platform" Please don't extract any of the internal toolkit zip files manually. – Praminda Sep 12 '19 at 03:19
  • @Praminda Thanks! I had checked here, docs.wso2.com/display/MG301/Installation+Prerequisites. With your instructions, 1. I extracted the toolkit zip file to a different location (D: drive). Before it was C: drive. 2. Cleared the old toolkit location from PATH variable present under System Variables. 3. Then I opened the /bin directory of the toolkit on command prompt. 4. Ran the micro-gw init . It's giving "You must set the JAVA_HOME variable before running Micro-Gateway Tooling.". It's already setup in System Variable as JAVA_HOME, value = C:\Program Files\Java\jdk1.8.0_221\bin. – Sushant W Sep 12 '19 at 10:20
  • @Praminda I added new extracted \bin directory to the PATH variable. This resolved the JAVA_HOME related error. 1. After running the micro-gw init on the bin directory of the toolkit, it initialized the project there itself and also extracted "platform" directory under \lib. 2. Then I ran the sample service with ballerina command. 3. I copied the open API definition file in api_definitions folder and ran the micro-gw build command. Now it's giving the same error as before "Could not find or load main class org.wso2.apimgt.gateway.cli.cmd.Main". – Sushant W Sep 12 '19 at 10:41
  • @Praminda in addition to above, this is where I was referring the steps, https://www.chakray.com/whats-new-wso2-api-microgateway-3-0/. Appreciate your help so far! Could you please give me further directions? – Sushant W Sep 12 '19 at 10:41

1 Answers1

1

Problem is with the init command not the build command. Init command is suppose to setup the TOOLKIT after the first use. It should extract the platform.zip file and copy all of the required resources to relevant places for you.

I hope you get the Project ___ successfully initialized message after running the init command. Just check $TOOLKIT_HOME/logs/ directory to see if there are any information on the log file.

If the log file also doesn't help, as a workaround, copy all the .jar files inside $TOOLKIT_HOME/lib/gateway/platform and $TOOLKIT_HOME/lib/gateway/cli to $TOOLKIT_HOME/lib/platform/bre/lib and try again, that should work.

Also please report this issue at https://github.com/wso2/product-microgateway/issues

Praminda
  • 565
  • 4
  • 8
  • @sushant-w Did the suggestion work? Were you able to resolve the issue? – Praminda Sep 18 '19 at 04:16
  • thanks for answering and reaching back! The problem that I noticed that there was some ballerina related system environment variable got added on it own, and after removing the build worked. However, I tried this with the Microgateway 2.6.0 version now. I haven't stored the ballerina variable so can't really put here, but there is one that got auto-added in the PATH variable and that seems to be ok. Only when it was a stand-alone variable it caused build issues. – Sushant W Sep 24 '19 at 11:40