worklight-adaptersworklight-serverworklight-studioworklight-runtime

Getting Error from IBM Workilght Server [It is not a function, it is \"object\".]


Using IBM Worklight version 6.1.0.02-20160314-1430

Implemented AES at adapter with reference to below link. https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/server-side-development/javascript-adapters/using-java-adapters/

Its working fine as expected in Eclipse in my local server. Generated war file and same given deployment for server. From server when I am trying to accessing getting below error response.

Below things are crosschecked.

  1. Collected war file from server, crosschecked for class file and its present in that

  2. Restart of server is taken after war file deployment

I am unable to identify where the bug is.

Error response from Server :

{
  "status": 200,
  "invocationContext": null,
  "errorCode": "PROCEDURE_ERROR",
  "errorMsg": "Procedureinvocationerror.EcmaError: TypeError: Cannotcallpropertyencryptinobject[   JavaPackagecom.winjit.EncryptionDecryption ].Itisnotafunction, itis\"object\". (API_Adapter-impl.js#7)",
  "invocationResult": {
    "isSuccessful": false,
    "warnings": [

    ],
    "errors": [
      "Ecma Error: TypeError: Cannot call property encrypt in object [JavaPackage com.winjit.EncryptionDecryption]. It is not a function, it is \"object\". (API_Adapter-impl.js#7)"
    ],
    "responseID": "3161",
    "info": [

    ]
  }
}

Solution

  • This error due to because of JDK mismatch of development server (Eclipse) and Server(Web sphere). Server is running on JDK 1.6. I downgraded my Eclipse's Java Version. Steps as follows(on mac).

    1. Eclipse -> Preferences -> Java -> Compiler
    2. Select Compiler compliance lever -> 1.6
    3. Eclipse -> Preferences -> Java ->Installed JREs
    4. Add JDK 1.6 location (/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home)
    5. Apply ok
    6. Rebuild project (Restart server if necessary)
    7. Give war file deployment to server which is re-generated bin folder

    Its working for me now as expected