我无法在Glassfish上部署Web应用程序。发生此问题的代码与我在javaapp中用于测试的代码相同,并且可以正常工作。
mdrae_summary <- function(data, lev=NULL, model=NULL) {
c(MdRAE=median(abs(data$pred - data$obs)/data$obs))
}
model <- train(
close_price~ ., data = train.data, method = "knn",
trControl = trainControl("cv", number = 10, summaryFunction = mdrae_summary),
preProcess = c("center", "scale"),
metric = "MdRAE",
tuneLength = 10
)
Stacktrace:
List<temp> tmp = new ArrayList<>();
tempconvert tc = new tempconvert();
SparkSession spark = SparkSession.builder()
.master("local")
.appName("MongoSparkConnectorIntro")
.config("spark.mongodb.input.uri", "mongodb://127.0.0.1/temperature.templog")
.config("spark.mongodb.output.uri", "mongodb://127.0.0.1/temperature.templog")
.getOrCreate();
JavaSparkContext jsc = new JavaSparkContext(spark.sparkContext());
public List<temp> getdata(String query) {
Dataset<Row> df = MongoSpark.load(jsc).toDF();
df.createOrReplaceTempView("temp");
Dataset<Row> data = spark.sql("select * from temp");
data.foreach((ForeachFunction<Row>) row ->{
tmp.add(tc.totemprow(row));
});
return tmp;
}