Error in file(con, “w“) : cannot open the connection
Closed this issue · 0 comments
icejean commented
When try to load R source scripts into remote R process through Rserve, sometimes we will get this error message:
package test.jean;
import java.util.Properties;
import org.math.R.RserveSession;
import org.math.R.RserverConf;
public class RserveTest {
public static void main(String args[]) {
try {
Properties prop = new Properties();
prop.setProperty("tls", "true");
RserverConf rconf = new RserverConf(host, 6311, "user", "password", prop);
RserveSession r = (RserveSession)new RserveSession(System.out, null, rconf);
// create java variable from R command
double[] rand = (double[]) r.eval("rnorm(10)");
// Use r.eval() to source script will cause java.lang.NullPointerException
//r.eval("source(\"/home/jean/R/testChinese.R\")",false);
// So r.voidEval() to load.
r.voidEval("source(\"/home/jean/R/testChinese.R\")");
r.eval("testChinese()");
System.out.println(r.asString(r.eval("rc$st")));
r.end();
} catch (Exception e) {
e.printStackTrace();
}
}
}
source("/home/jean/R/testChinese.R")
R! Error in file(con,"w"):无法打开链结
此外: Warning message:
In file(con,"w"):
无法打开文件'/tmp/RtmpGLcOIq/file7ccc5c5ae965.sh': 没有那个文件或目录
at org.math.R.Rsession.voidEval(Rsession.java:864
at org.math.R.Rsession.voidEval(Rsession,java:885)
at MelbourneRserve.calRServe(MelbourneRserve.java:70)
at MelbourneRserve .doGet(MelbourneRserve.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.iava:670)
<22 internal lines>
testChinese.R
testChinese<-function(){
test<-c("Rserve中文测试。")
rc<<-list(st=test)
return(rc)
}
The reason is that the temporary directory created by Rserve damon is deleted, need to restart Rserve to created a temporary directory again to address it, it hard to find out the real reason, so I paste it here incase of someone gets the issue.