API build fails in WSO2 API Microgateway 3.1.0 - wso2

I am new to WSO2 microgateway and was following the steps given in the documentation : "https://docs.wso2.com/display/MG310/Quick+Start+Guide+-+Binary" for exposing the Petstore service via microgateway.
I was able to initialize the API using the swagger file as given in the steps. The Petstore project is also created under the project directory. But when i try to build the project as given in Step 1.2, it fails with an error as shown below. Need suggestions to resolve this issue.
In the ballerina-internal.log file, i get the below error.
[2020-07-16 21:13:19,009] SEVERE {b7a.log.crash} - Array index out of range: 0
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at org.ballerinalang.nativeimpl.jvm.interop.JMethodResolver.validateArgumentTypes(JMethodResolver.java:194)
at org.ballerinalang.nativeimpl.jvm.interop.JMethodResolver.validateMethodSignature(JMethodResolver.java:148)
at org.ballerinalang.nativeimpl.jvm.interop.JMethodResolver.resolve(JMethodResolver.java:107)
at org.ballerinalang.nativeimpl.jvm.interop.JInteropMethodValidator.resolveJMethod(JInteropMethodValidator.java:74)
at org.ballerinalang.nativeimpl.jvm.interop.JInteropMethodValidator.validateAndGetJMethod(JInteropMethodValidator.java:61)
at ballerina.jvm.$value$InteropValidator.validateAndGetJMethod(interop.bal:90)
at ballerina.jvm.$value$InteropValidator.call(interop.bal)
at ballerina.compiler_backend_jvm.interop.interop_method_gen.createJMethodWrapper(interop/interop_method_gen.bal:136)
at ballerina.compiler_backend_jvm.interop.interop_method_gen.createJInteropFunctionWrapper(interop/interop_method_gen.bal:128)
at ballerina.compiler_backend_jvm.interop.external_method_gen.createExternalFunctionWrapper(interop/external_method_gen.bal:180)
at ballerina.compiler_backend_jvm.jvm_package_gen.generateClassNameMappings(jvm_package_gen.bal:477)
at ballerina.compiler_backend_jvm.jvm_package_gen.generatePackage(jvm_package_gen.bal:149)
at ballerina.compiler_backend_jvm.jvm_package_gen.generateDependencyList(jvm_package_gen.bal:120)
at ballerina.compiler_backend_jvm.jvm_package_gen.generatePackage(jvm_package_gen.bal:142)
at ballerina.compiler_backend_jvm.jvm_package_gen.generateDependencyList(jvm_package_gen.bal:120)
at ballerina.compiler_backend_jvm.jvm_package_gen.generatePackage(jvm_package_gen.bal:142)
at ballerina.compiler_backend_jvm.jvm_package_gen.generateDependencyList(jvm_package_gen.bal:120)
at ballerina.compiler_backend_jvm.jvm_package_gen.generatePackage(jvm_package_gen.bal:142)
at ballerina.compiler_backend_jvm.jvm_package_gen.generateDependencyList(jvm_package_gen.bal:120)
at ballerina.compiler_backend_jvm.jvm_package_gen.generatePackage(jvm_package_gen.bal:142)
at ballerina.compiler_backend_jvm.main.generateJarBinary(main.bal:86)
at ballerina.compiler_backend_jvm.main.main(main.bal:60)
at ballerina.compiler_backend_jvm.___init.$lambda$main$(compiler_backend_jvm)
at ballerina.compiler_backend_jvm.___init$$Lambda$11.000000001107AEE0.apply(Unknown Source)
at org.ballerinalang.jvm.scheduling.SchedulerItem.execute(Scheduler.java:426)
at org.ballerinalang.jvm.scheduling.Scheduler.run(Scheduler.java:218)
at org.ballerinalang.jvm.scheduling.Scheduler.runSafely(Scheduler.java:191)
at org.ballerinalang.jvm.scheduling.Scheduler$$Lambda$6.0000000010F6DAF0.run(Unknown Source)
at java.lang.Thread.run(Thread.java:813)

Looking at the responses in the comments it looks like the external jdk is not fully compatible with mgw. Not sure on the exact reason though. Here is a bit more background on what going on during the build command and a possible workaround to force mgw use internal jdk.
All mgw distributions (toolkit/runtime) including the binary distribution, contains a jdk internally which is fully compatible with the ballerina version used in the mgw. However during the execution of mgw toolkit command it checks for externally installed jdks (by looking at JAVA_HOME variable) and pick it as the jdk if a compatible version is found in the system. Otherwise it will use the internal jdk.
So to avoid mgw from picking up external jdk, we should set JAVA_HOME variable to "" or invalid location. To do that open micro-gw.bat (assume you are on windows) file in the <TOOLKIT_HOME>/bin directory and around line 55 after SET HOME_CACHE=%MICROGW_HOME%\lib\gateway-balo add SET JAVA_HOME= as command. After the change code block around above line will look like below.
.
.
.
SET PATH=%BALLERINA_HOME%\bin\;%PATH%
SET JAVA_PATH=%MICROGW_HOME%\lib\jdk8u202-b08-jre
SET HOME_CACHE=%MICROGW_HOME%\lib\gateway-balo
REM ******* Below is the line we added to reset the JAVA_HOME *******
SET JAVA_HOME=
REM Check JAVA availability
if EXIST "%JAVA_HOME%" (
ECHO JAVA_HOME: %JAVA_HOME%
.
.
.
Save the file and try the build command again. It should work.

Related

Hadoop/HDFS 3.1.1 (on Java 11) Web UI crash when loading the file explorer? [duplicate]

This question already has answers here:
What is the replacement for javax.activation package in java 9?
(6 answers)
Closed 4 years ago.
After start-dfs.sh, I can navigate to http://localhost:9870. The NameNode seems to be running just fine.
Then I click on "Utilities -> Browse the file system" and I get this prompted in the web browser:
Failed to retrieve data from /webhdfs/v1/?op=LISTSTATUS: Server Error
Digging into the logfile ($HADOOP_HOME/logs/hadoop-xxx-namenode-xxx.log), I find this:
2018-11-30 16:47:25,097 WARN org.eclipse.jetty.servlet.ServletHandler: Error for /webhdfs/v1/
java.lang.NoClassDefFoundError: javax/activation/DataSource
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.(RuntimeBuiltinLeafInfoImpl.java:457)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.(RuntimeTypeInfoSetImpl.java:65)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:133)
So a class is missing. Why is this and how do I fix the problem?
Java 9 deprecated the java.activation module. Java 11 removed it completely.
Java 9 and Java 10 users could add the module back on Hadoop's classpath. Put this in $HADOOP_CONF_DIR/hadoop-env.sh(not tested):
export HADOOP_OPTS="${HADOOP_OPTS} --add-modules java.activation "
Java 11 users must first download the jar dependency and make it available on the classpath. But were does it go?
I found that putting the jar in any one of these locations will make Hadoop automagically pick it up with the effect that the online file explorer start working:
$HADOOP_HOME/share/hadoop/common
$HADOOP_HOME/share/hadoop/common/lib
$HADOOP_HOME/share/hadoop/mapreduce
$HADOOP_HOME/share/hadoop/mapreduce/lib
Not sure what exactly the consequences are putting the file in one or the other folder. But, I like to confine my hacks as much as possible and since I already have a separate configuration directory (i.e., not $HADOOP_HOME/etc/hadoop) I'd like to put it there. Having the jar file in any other location also requires of us to add this path to the HADOOP_CLASSPATH variable.
So, copy-paste into your terminal:
URL=https://jcenter.bintray.com/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar
wget $URL -P $HADOOP_CONF_DIR/lib
echo 'export HADOOP_CLASSPATH+=" $HADOOP_CONF_DIR/lib/*.jar"' >> $HADOOP_CONF_DIR/hadoop-env.sh
As a final note, I think it's safe to say that one can not expect Hadoop to work well on anything but really old Java versions. Googling reveals that still open tickets exist for Java 9, 10 and 11. So essentially, this is a Hadoop problem. Having that said, although we solved one problem of getting the online file explorer to work, there will for sure be many other issues down the line.

How to use OpenDDS 3.13 Security

Recently I try to use OpenDDS 3.13 Security.
I also followed the OpenDDS security manual and make and build project.
Configure command like this:
$./configure --security --xerces --openssl && make
Bulid and make project successful but when I run the example which located in DDS_ROOT/tests/DCPS/Messenger have trouble.
I get the following output:
$./publisher -DCPSConfigFile rtps_uni.ini
Starting publisher
Starting publisher with 1 args
(26771|139728132269888) ERROR: DomainParticipantImpl::enable, Unable to validate local identity. SecurityException[-1.0]: GUID_UNKNOWN passed in for candidate_participant_guid
(26771|139728132269888) ERROR: DomainParticipantFactoryImpl::create_participant, unable to enable DomainParticipant.
publisher.cpp:103: main() ERROR: create_participant failed!
Can I please get some directions on how to solve this issue?
Mr.Simpson reply my question, he said that use
rtps_disc_sec.ini instead of rtps_uni.ini
source is here:
https://github.com/objectcomputing/OpenDDS/issues/934

Why does Visual Studio 2017 fail to generate REST API client for Swagger Petstore?

I'm playing around with using Swagger / OpenAPI docs/specs to generate REST API client code in C#, but I'm running into several problems.
Most notably - when trying to use the Swagger.io Petstore example as a starting point:
Using the VS 2017 Add > REST API client option in VS 2017, I don't get any code produced - instead an error is shown:
Generating client code and adding to project started
Generate client code for REST API with following parameters:
REST API Name: OpenApiClientClient, Base namespace: OpenApiClient, Metadata file path: C:\Users\Marc\AppData\Local\Temp\WebToolsAutoRest\OpenApiClientClient\201807162213351660\swagger.json
[Info]AutoRest Core 0.16.0.0
[Info]Initializing modeler.
[Info]Initializing modeler.
[Info]Parsing swagger json file.
[Info]Generating client model from swagger model.
[Fatal]Error generating client model: Collection format "multi" is not supported (in parameter 'status').
Exception: There was an error during code generation when trying to add a client for the REST API
Generating client code and adding to project failed
Adding REST API client for failed
So if the Swagger sample app isn't compatible - how will others be?? (and I tried a few others, all with the same results, unfortunately).
What's wrong here? Am I missing something, do I need to add some extra tooling to VS 2017 to make this work?
UPDATE:
OK, so I now tried to install Autorest using npm directly:
npm install -g autorest
This appears to work - no errors shown or anything.
But trying to run Autorest - with a set of command line parameters, or even just on its own - results in an error:
AutoRest -CodeGenerator CSharp -Modeler Swagger
-Input https://petstore.swagger.io/v2/swagger.json
-Namespace Services.UserServiceClient -OutputDirectory d:\projects
-AddCrendentials true
or just
AutoRest <kbd>Enter</kbd>
results in:
AutoRest code generation utility [version: 2.0.4280; node: v9.9.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Failure:
Error: Unable to start AutoRest Core from C:\Users\Marc.autorest\#microsoft.azure_autorest-core#2.0.4280\node_modules\#microsoft.azure\autorest-core
Error: Unable to start AutoRest Core from C:\Users\Marc.autorest\#microsoft.azure_autorest-core#2.0.4280\node_modules\#microsoft.azure\autorest-core
at main (C:\Users\Marc\AppData\Roaming\npm\node_modules\autorest \dist\app.js:232:19)
at
Any further ideas?
Visual Studio 2017 is using a very old version of AutoRest. The issue you are seeing is this one which was fixed in AutoRest v. 1.0. As explained in the comments in that issue:
Are you referring to the autorest version that's built-into visual studio? -- That's incredibly old, and we didn't update that (we've changed the whole way autorest works).
You are going to need to install node and use autorest from the command line.
Looks like it's not possible to update AutoRest used by Visual Studio 2017, so you'll need to call AutoRest directly.
I also had this problem so I built a tool for it called REST API Client Code Generator. I worked in teams where we used tools like AutoRest, NSwag, and Swagger Codegen to generate our REST API Clients and it always annoyed me that the "Add New - REST API Client..." tooling in Visual Studio didn't always work and was very troublesome when it was time to re-generate the client
This would add the OpenAPI specification file (Swagger.json) to the project and set a custom tool so that every time changes are made to it the REST API Client code is re-generated. You can also right click on the Swagger.json file and switch code generators
I built the tool mainly for personal use and for use within my teams but if you find it useful and think it lacks something you really need then please reach out
Try running autorest --reset. This worked on windows with node v8.12.0. Prior to running that command I was getting the same error.

Running SonarQube analysis scan - SonarSource build-wrapper

I'm new to running SonarQube scans and I get this error message in the log in Jenkins:
16:17:39 16:17:36.926 ERROR - The only way to get an accurate analysis of your C/C++/Objective-C project is by using the SonarSource build-wrapper. If for any reason, the use of the build-wrapper is not possible on your project, you can bypass it with the help of the "sonar.cfamily.build-wrapper-output.bypass=true" property. By using that property, you'll switch to an "at best" mode that could result in false-positives and false-negatives.
Can someone please advise where I can find and run this SonarSource build-wrapper?
Thanks a lot for your help!
To solve this issue, download the Build Wrapper directly from your SonarQube Server, so that its version perfectly matches your version of the plugin:
Build Wrapper for Linux can be downloaded from URL
http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip
Unzip the downloaded Build Wrapper,
Configure it in your PATH because it's just more convenient
export PATH=$PATH:/path/where/you/unzip
Once done, Run below commands.
build-wrapper-linux-x86-64 --out-dir <dir-name> <build-command>
build-wrapper-linux-x86-64 --out-dir build_output make clean all
Once all this done, you have to modify your sonar-project.properties file with following line. Note the dir-name is same directory which we defined in previous command.
sonar.cfamily.build-wrapper-output=<dir-name>
and then you can run the sonar scanner command.
sonar-scanner
this will do the analysis against your code. For more details, you can check this link.
Contacted support, turns out this was caused by missing the argument sonar.cfamily.build-wrapper-output in the scanner begin command.
Build wrapper downloads:
Linux: https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
macOS: https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip
Windows: https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip
Some links covering how to run the build wrapper:
https://docs.sonarqube.org/latest/analysis/languages/cfamily/
https://blog.sonarsource.com/with-great-power-comes-great-configuration/

Exe built using pyinstaller on a Django with pylucene app giving JVM error

I am getting an error:
"Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries"
The error arises when I try to execute my exe file.
I have created exe file through pyinstaller on a django application. Application uses pylucine library. I think it may be the issue of error.
How to fix the error?
Since I can't be certain given you've provided very few details here is a shot in the dark to help solve your problem:
First, try removing the jvm.dll file that gets packaged with the pyinstaller -D youmodule.py command (for now work with the directory command rather than -F option). The reason why is here.
With that jvm.dll file gone, you should start seeing the actual error code - and with that the java class or dependency that isn't being loaded.
If it's a java class that isn't being properly loaded then you know instantly it must not be correcly represented in the classpath environment variable and you should do everything in your power to make sure it is:
e.g.: os.environ['CLASSPATH'] += 'the/path/to/the/jar'
Otherwise, consider bulking up your question with more details, especially if you can get a more meaningful error output.
I had the same error trying to run a .exe built with PyInstaller through wine.
My problem went away by adding C:\Program Files\Java\ [your jdk version here] \jre\bin\server to the PATH environment variable in wine - I suppose it might be the same in Windows.
It also reappeared if I tried to build with C:\Program Files\Java\ [your jdk version here] \jre\bin\server in my PATH, so I had to build without it and then append it before running it (I have no explanation as to why this happens).