Calling java code from javascript adapters

301 Views Asked by At

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)

1

There are 1 best solutions below

1
Vivin K On

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.