简体   繁体   中英

How to call java method from a javascript adapter

In Javascript Adapter, I call a java function similar as below:

var reqTag = new com.awesome.project.bean.prop.Record;
reqTag.setServiceID("2039");

And the server return error in log showing that:

[JavaPackage com.awesome.project.bean.prop.Record] is not a function, it is object. (javascriptAdapter.js#2676)

Server and java(dummy.jar) both are using 1.7. This is the way we add the jar file to javascript adapter in pom.xml

<dependency>
        <groupId>com.awesome.project</groupId>
        <artifactId>dummy</artifactId>
        <version>1.46</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/lib/dummy.jar</systemPath>
</dependency>

The MobileFirst Server 8.0 is using IBM JDK1.7.

Typically in MobileFirst Foundation this error happens when the Java version that the server uses (per the definition in the system) is not the same as the Java version specified in the adapter's pom.xml file (which is used to compile the adapter), or vice versa.

I suggest to make sure that both are Java 1.8. See if this then works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM