ECMA TypeError Java class call from Worklight adapter

I saw a number of questions on this issue, but no convincing answers. I find it difficult to call a Java class from my implementation of the Worklight adapter. I replaced my code with the code from the Java Worklight Java Adapter tutorial and it fails the same way. Also, I found an answer on the IBM website that says that the Java 1.7 compiler can cause this problem and use Java 1.6 instead. I have confirmed that my compiler in Eclipse is Java 1.6.

Screenshot of Eclipse and code path

My Java classes start with com (e.g. com.worklight.customcode). I tried using public static methods (using the correct syntax), as well as instantiating the object and calling the method. As mentioned above, I also confirmed that I am using the Java 1.6 compiler.

:

:

function addTwoIntegers(a,b){
    return {
        result: com.worklight.customcode.Calculator1.addTwoIntegers(a,b)
    };
}

Java ( IBM Worklight):    com.worklight.customcode;

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;
    }

}

:

TypeError: addTwoIntegers [JavaPackage com.worklight.customcode.Calculator1]. , "". (% 2FUsers% 2Fhome% 2Fdev% 2Fapp% 2Fappprj% 2Fadapters% 2Fadapter/-impl.js # 26)     FWLSE0101E: : null

:

+5
5

, CLASSPATH , (-) Eclipse.

, , .project, buildCommand, . buildCommands Java- JavaScript Eclipse.

<buildSpec>
    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
        <arguments>
        </arguments>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.wst.common.project.facet.core.builder</name>
        <arguments>
        </arguments>
    </buildCommand>
    <buildCommand>
        <name>com.worklight.studio.plugin.WorklightProjectBuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.wst.validation.validationbuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
</buildSpec>

.project Worklight (, myproject/.project). , , , Java JavaScript.

. http://www.ibm.com/developerworks/rational/library/server-side-mobile-application-development-1/

, . , (!!). , , . .project , buildCommand . externalToolBuilding, -, IDE, Eclipse, .project , . ( , Sublime, ).

, , Worklight Eclipse - ( ). . (ack!).

, - .

+2

, - . , Java, , worklight.war. , ECMA .

, , - WL, Java UP DOWN . eclipse .project, .

, , , // java Newclass eclipse, , . -clean , .

+2

, . Java "" :

public static int addTwoIntegers(Object first, Object second) {
    logger.info("addTwoIntegers invoked" + first.getClass() + "," + second.getClass());
    return first + second;
}

. , . ...

0

- , , . Eclipse 4.4, Worklight 6.2, WebSphere Application Server 8.5.5.1, Java 1.7. , Run As > Invoke Worklight Procedure.

, , Adapters.war . : JARs... > /bin/Adapters.war. .

0

, . , , , :

1) , Java , . JRE . , , , 1.7.0, 1.7.49

2) , Java, , . , , , .

3) .project:

4) , ,

5), , "" WAR

0

All Articles