我正在尝试将外部罐子导入芭蕾舞女演员。在这种情况下,它是从maven-central下载的nd4j-native-platform-1.0.0-beta5.jar。我不知道是什么问题。
我的Ballerina.toml文件的配置如下:
Ballerina.toml
[project]
org-name= "user_name"
version= "0.1.0"
[platform]
target = "java8"
[[platform.libraries]]
path = "/Users/username/Code/Workspace6/ballerina-hackathon/ml-connector/java_dependencies/deeplearning4j-modelimport-1.0.0-beta5.jar"
modules = ["ml_service"]
要加载的模块“ ml_service”中的文件(load_model.bal):
load_model.bal
import ballerinax/java;
function loadModel() returns handle = @java:Method {
name: "ClassPathResource",
class: "org.nd4j.linalg.io"
} external;
public function main() {
var load = loadModel();
}
尝试构建时遇到的错误如下:
computername:ml-connector username$ ballerina build ml_service
Compiling source
user_name/ml_service:0.1.0
Creating balos
target/balo/ml_service-2019r3-java8-0.1.0.balo
error: user_name:ml_service:load_model.bal:9:1: {ballerinax/java}CLASS_NOT_FOUND message=org.nd4j.linalg.io
答案 0 :(得分:4)
我发现了问题所在,我所拥有的jar中没有ClassPathResource类。为此,应该已经在load_model.bal文件中修改了代码。必须将函数classPathResource声明为构造函数,而不是像我之前声明的那样声明为Method。它还必须采用字符串类型的参数。我已经附加了下面使用的代码。
load_model.bal
import ballerinax/java;
import ballerina/io as _;
function loadModel(handle path) returns handle = @java:Constructor {
class: "org.nd4j.linalg.io.ClassPathResource"
} external;
public function main() {
var load = loadModel(java:fromString("model_path"));
}