Note that there are some explanatory texts on larger screens.

plurals
  1. POECMA TypeError calling Java class from Worklight adapter
    primarykey
    data
    text
    <p>I've seen a number of questions about this issue but no conclusive answers. I am having trouble calling a Java class from my Worklight adapter implementation. I replaced my code with the code from the IBM Worklight Java Adapter tutorial and it fails in the exact same way. Furthermore I found a response on IBM's site saying the Java 1.7 compiler might cause this problem and to use Java 1.6 instead. I validated that my compiler in Eclipse is Java 1.6.</p> <p><img src="https://i.stack.imgur.com/mrQHF.png" alt="Screenshot of Eclipse and code path"></p> <p>My Java classes all begin with com (e.g. com.worklight.customcode). I've tried both calling public static methods (using the proper syntax) as well as instantiating the object and calling the method. As mentioned above, I've also validated I'm using the Java 1.6 compiler. </p> <p>Here are some code samples: </p> <p>Adapter implementation file:</p> <pre><code>function addTwoIntegers(a,b){ return { result: com.worklight.customcode.Calculator1.addTwoIntegers(a,b) }; } </code></pre> <p>Java file (unedited IBM Worklight sample): package com.worklight.customcode;</p> <pre><code>import java.util.logging.Logger; public class Calculator1 { private final static Logger logger = Logger.getLogger(Calculator1.class.getName()); public static int addTwoIntegers(int first, int second){ logger.info("addTwoIntegers invoked"); return first + second; } public int subtractTwoIntegers(int first, int second){ logger.info("subtractTwoIntegers invoked"); return first - second; } } </code></pre> <p>Error in the console: </p> <blockquote> <p>TypeError: Cannot call property addTwoIntegers in object [JavaPackage com.worklight.customcode.Calculator1]. It is not a function, it is "object". (%2FUsers%2Fhome%2Fdev%2Fapp%2Fappprj%2Fadapters%2Fadapter/adapter-impl.js#26) FWLSE0101E: Caused by: null</p> </blockquote> <p>Some of the related questions are: </p> <ul> <li><a href="https://stackoverflow.com/questions/15826456/ecma-error-typeerror-cannot-call-property">Ecma Error: TypeError: Cannot call property</a></li> <li><a href="https://stackoverflow.com/questions/15428243/i-want-to-call-a-java-class-from-the-worklight-adapter">i want to call a java class from the worklight adapter</a></li> <li><a href="https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014867695" rel="nofollow noreferrer">https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014867695</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload