[英]Rserve Exception “eval failed, request status: error code: 127”
I tried to execute some r code from java using Rserve: 我试图使用Rserve从Java执行一些r代码:
try {
RConnection conn = new RConnection();
conn.eval("write.csv(PoS, file = 'C:/test/PoS.csv',row.names=FALSE)");
} catch (REngineException eR) {
System.err.println("Exception: "+ eR);
throw new TestException("syntax error on eval on R code");
} catch(Exception e){
e.printStackTrace();
throw new TestException("parseAndEval did not generate an exception on syntax error" );
}
I got the eval failed error. 我收到评估失败的错误。 But I can successfully execute the Rcode in R: 但是我可以在R中成功执行Rcode:
write.csv(PoS, file = 'C:/test/PoS.csv',row.names=FALSE)
I am sure that Rserve()
has been started on the R side, and other statements like 我确定Rserve()
已在R端启动,并且其他语句如
conn.eval("iris");
is possible. 是可能的。
I have solved this issue. 我已经解决了这个问题。 The matrix PoS
need to be reloaded, every time I establish a new Rconnection, or save it in the default workspace image alternatively. 每次我建立新的Rconnection时,都需要重新加载矩阵PoS
,或者将其保存在默认的工作区映像中。
To get the proper error message, use this instead of simple eval 要获取正确的错误消息,请使用此代替简单的eval
REXP rResponseObject = rServeConnection.parseAndEval("try(eval("+R_COMMAND_OR_SOURCE_FILE_PATH+"),silent=TRUE)");
if (rResponseObject.inherits("try-error")) {
LOGGER.error("R Serve Eval Exception : "+rResponseObject.asString());
}
This logger prints exact error thrown from R. 该记录器打印从R引发的确切错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.