Ecma error: TypeError: cannot call property

I wrote java code in an adapter in a worklight project. when I try to call the java method, I get an error

"responseID": "6", "errors": {Ecma Error: TypeError: Cannot call the downloadFile property in the JavaPackage java.classes.FileIOPlugin]. This is not a function, it is \ "Object \".}

I followed the procedure in the following link. Using Java in adapters

this is my project structure. Is there something wrong with this structure or should I add something else to this?

enter image description here

This is how I try to call the non-static java method in adapter-impl.js

function downloadFile() {
    var fileInstance = new com.worklight.JavaCode.FileIOPlugin();
    return
    {   result: fileInstance.downloadFile();    };

}

+5
source share
4 answers

.

  • Java 1.6, JRE 1.6:

Compiler levelJRE version

+6

, com, . "com.classes".

0

:

var fileInstance = new com.worklight.JavaCode.FileIOPlugin()
0
source

Check the .project file and make sure that it has the correct buildCommand tags.

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

Read more: ECMA TypeError calls a Java class from a Worklight adapter

0
source

All Articles