Rshiny使用mailR发送电子邮件| jCall错误

时间:2017-05-07 00:02:39

标签: r shiny shiny-server rjava

以下是我正在构建的RShiny应用服务器端运行的mailR代码。此应用程序的目的是在金融市场中发生某种情况时发送电子邮件。当我在一个单独的脚本(不是在RShiny应用程序中)自己运行此代码时,它运行正常。在RShiny应用程序中运行时,应用程序崩溃并出现以下错误。

sender <- "FROM@gmail.com"
  recipients <- c("TO@gmail.com")
  body.string <- "words words words words words punchline"
  send.mail(from = sender,
            to = recipients,
            subject = "***STOPLOSS ALERT***",
            body = body.string,
            smtp = list(host.name = "smtp.gmail.com", port = 465, 
                        user.name = "FROM@gmail",            
                        passwd = "******", ssl = TRUE),
            authenticate = TRUE,
            send = TRUE)

错误讯息:

Warning in if (file.exists(body)) body <- readChar(body, file.info(body)$size) :
  the condition has length > 1 and only the first element will be used
Warning: Error in .jcall: java.lang.NoSuchMethodException: No suitable method for the given parameters
Stack trace (innermost first):
    56: <Anonymous>
    55: stop
    54: .jcheck
    53: .jcall
    52: .jrcall
    51: email$setMsg
    50: send.mail
    43: isolate
    42: server [C:\Users\****/app.R#135]
     1: runApp
    Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  java.lang.NoSuchMethodException: No suitable method for the given parameters

由于代码在Shiny应用程序之外可以自行运行,我的想法是RShiny在某种程度上导致了这一问题在较低级别的Java代码上出错。任何建议/提示将不胜感激。

1 个答案:

答案 0 :(得分:0)

您可以尝试执行如下所示的简单代码,并告诉我是否仍然出现任何错误吗?

SELECT id, category, SUM(spend),
       SUM(spend) / SUM(SUM(spend)) OVER (PARTITION BY id) as ratio
FROM table
GROUP BY id, category;