Calling java code from javascript adapters - ibm-mobilefirst

Facing the below issue when trying to invoke java code from javascript adapters with Mobilefirst 8.0.
Sample code from the below link is used for testing.
https://github.com/MobileFirst-Platform-Developer-Center/Adapters/tree/release80
Project structure
com.ibm.mfp.server.js.adapter.internal.JavascriptManagerImpl E FWLST0904E: Exception was thrown while invoking procedure: subtractTwoIntegers in adapter: UsingJavaInJavaScriptAdapters
org.mozilla.javascript.EcmaError: TypeError: [JavaPackage com.sample.customcode.Calculator] is not a function, it is object. (UsingJavaInJavaScriptAdapters-impl.js#24)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3951)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3929)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3962)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3981)
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4036)
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4024)
at org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2502)

This normally happens when your server is running a version of Java that is different from the one with which the adapter was built.For example, MFP server is running on JDK 1.7, while the adapter has been built using JDK 1.8.
Ensure your server is running the same version of Java that is used to build the adapters.

Related

Java JUnit JVM_EnqueueOperation() stubbed

I get this error while trying to run a JUnit Test on eclipse Oxygen Using Ibm's jdk8.
Is there any known bug in this version of jdk? How can I fix/avoid it?
Seems like the unit test uses PowerMock, which does not currently support IBM JDK.
PowerMock tries to load an agent via HotSpot Attach Mechanism, but it should use J9 attach mechanism instead.
See the following issues for details:
https://github.com/eclipse/openj9/issues/3441
https://github.com/powermock/powermock/issues/970
Worked by adding the Mocking-Library path as VM Argument to the JRE as already stated by apangin.
To do that:
Window→ Preferences → Java → Installed JREs: select JDK, edit it and add the following to Default VM Arguments:
-javaagent:<YOUR_M2_REPO_PATH>/org/jmockit/jmockit/1.9/jmockit-1.9.jar

No supported platforms were detected to migrate issue with mfpmigrate from mobilefirst 6.3 to 8.0

I tried the migration process of mobilefirst from v6.3 to v8.0. I installed the migration tool. I tried to migrate a sample program in IBM mobilefirst v6.3 to v8.0 using the command mfpmigrate as shown below. Although the input to the command is a v6.3 program, it says that No supported platforms detected.
D:\MobileFirst>mfpmigrate client --in AdapterBasedAuth\apps\DoubleStepAuth --out
MigrationDemo
Error: An error occured during execution of command.
Error: No supported platforms were detected to migrate
Could you please help me resolve the above mentioned problems.
Thanks a lot in advance!
This is expected, as the sample application AdapterBasedAuthenticationHybridProject is not coming with any platforms. You need to first add a supported platform using MobileFirst Studio - iOS, Android etc...

Procedure invocation failed: ContextPath/authorization/v1/testtoken

I'm using mobilefirst 7.1 for eclipse juno on windows 7.
I tried to call default adapter which is created by mobilefirst it is showing an error
Procedure invocation failed: ContextPath/authorization/v1/testtoken
what might be causing the problem?
MobileFirst Platform Foundation 7.1 does not support Eclipse Juno. First use either Eclipse Kepler or Mars, install the latest available 7.1 build from the Eclipse Marketplace and see if it is failing still.
If it will continue to fail, provide full reproduction steps.

Worklight, Adapter-Based Authentication for Android, app does not exist on the server

Im new to Worklight, Im trying to run the AdapterBasedAuthenticationProject from the tutorial of IBM worklight. Sample here
After deployed the auth-adapter and build the app, this app run ok on the Worklight console. However, when I make the android version and run on virtual machine, I can not get the secret data.
When I click on "Get secret data" button on android, error occurs
[ERROR ] FWLSE0332E: The application AdapterBasedAuthApp for the environment android does not exist on the server. Cannot register this client. [project AdapterBasedAuthenticationProject]
Image here
Looks like you are using JRE 1.8 (Java 8). Note that Worklight does not support Java 8 - downgrade to either Java 6 or 7.
Make sure you have:
Added the Android environment
Deployed the Android environment (right-click on the your-app\android folder and select Run As > Build and Deploy)
Those are crucial steps in order for the server to recognize a request originating from Android
Also, I don't understand what do you mean by "virtual machine", as it is not obvious from the screen shot. It just looks like a resized browser window.
I encountered similar issue today. In my case Java version was not the issue the issue was incorrect wlAppVersion number in wlclient.properties,
make sure it is same as in application-descriptor.xml.

IBM Worklight Failing to start

Configuration: Eclipse (Juno) 4.2.2
IBM Worklight version: 6.2.0.01
Java version:
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
JDK: jdk1.7.0_71.jdk
Java Compiler: 1.7
My worklight studio was previously working and suddenly stops working after I had to force quit my eclipse. Even after reinstallation of the plugins, the error still recurs.
Here's a screenshot of the initial error log before 'Worklight server failed to start' and 'Failed to deploy application in the worklight server'. Any help to fix this issue will be deeply appreciated. Worklight studio issues like this is starting to get frustrating.
I uninstalled java from my mac. Reinstalled Java (JDK & JRE), new Eclipse (Juno 4.2.2) -> Then installed IBM Worklight Studio plugin. Figured it was the problem with Java as it was throwing the java exception 'unable to read the manifest'. Probably there was some issue after updating to Yosemite.
I had the same problem. You need to set correct IP for Worklight server. It doesn't work with "localhost" or "*".
It looks Java EE got corrupted somehow,
So as suggested the best approach would be to use a fresh Eclipse instance with a new plug-in installation and a new workspace as well. This way it makes sure everything is fresh and new.