1

我在 heroku 上使用 ClearDB MySQL,而不是默认给出的 Postgres。我的代码在我的本地机器上运行良好。这是我的下载文件方法:

public static void downloadFile(long id) throws Exception {

final Article doc = Article.findById(id);
        notFoundIfNull(doc);

    User current_user = User.find("byEmail", Security.connected()).first();

    if(!current_user.equals(doc.author)){
        SelectedArticles selectedArticle = SelectedArticles.find("byArticleAndReviewer", doc, current_user).first();
        if(selectedArticle == null)
        {
             SelectedArticles newSelected = new SelectedArticles(current_user, doc);
             newSelected.save();
             selectedArticle = newSelected;
        }
        selectedArticle.download();
    }

    response.setContentTypeIfNotSet(doc.article_pdf.type());
    renderBinary(doc.article_pdf.get(), doc.pdfName);
}

这是我在 Heroku 日志中看到的内容:

←[36m2012-05-09T01:29:41+00:00 app[web.1]:←[0m Caused by: java.lang.NullPointerE
xception
←[36m2012-05-09T01:29:41+00:00 app[web.1]:←[0m  ... 2 more
←[36m2012-05-09T01:29:41+00:00 app[web.1]:←[0m  at play.mvc.results.RenderBinary
.apply(RenderBinary.java:167)
4

0 回答 0