Playframework - 我的应用程序在apache-tomcat上无法正常工作

时间:2017-02-17 14:54:16

标签: java scala tomcat playframework

我在Play Framework 2.4.10(Java)中开发了一个应用程序,可以在apache-tomcat服务器上运行。

使用PlayFramework的插件创建.war文件。

我创建了一个本地服务器apache-tomcat,并且在部署之后完成演进在所有情况下都按预期发生,没有出现错误日志,只有正常的日志进程。应用程序的所有功能都可以正常运行,没有任何错误,崩溃或滞后。

当我将应用程序部署到Google Cloud Platform(GAE)服务器和其他公司的服务器时,会出现问题。

部署正常进行,但是当用户在某些情况下尝试保存新信息时,服务器不响应POST请求,并且浏览器正在等待来自服务器的响应。当用户多次点击保存按钮时,POST过程会保存数据,通常不会出现错误。

其他功能,如过滤信息,注销,访问注册页面,查询,更改,正常删除工作。只有当我在系统中更新,注册或验证时才会出现错误。

记录屏幕使用HTML PlayFramework本身的模板以及一些Scala语言提示。

这个奇怪的问题偶尔会发生。

我的表格Scala:

@(siteForm: play.data.Form[validators.SiteFormData], paises:Map[String,Boolean])

@import helper._
@import templates.bootstrap._

@views.html.admin.main("Cadastro de Sites") {
<div class="col-md-12">
    <div class="page-header header-biogas">
        <div class="btn-group btn-breadcrumb pull-right">
            <a href="@routes.AdminController.painel()" class="btn btn-default"><i class="fa fa-home"></i></a>
            <a href="@routes.SiteController.telaLista()" class="btn btn-default">Sites</a>
            <a disabled class="btn btn-default">Cadastro</a>
        </div>
        <h1 class="font-style"><i class="fa fa-globe" aria-hidden="true"></i> Cadastro de Site</h1>
    </div>
</div>
<div class="col-sm-5">
    <div class="panel panel-default">
        <div class="panel-heading">Cadastro de Sites</div>
        <div class="panel-body">
        @form(routes.SiteController.inserir(), 'class -> "form-horizontal", 'id -> "siteForm") {

            @if(siteForm.hasGlobalErrors) {
                <div class="form-group">
                    <label class="col-sm-3 control-label"></label>
                    <div class="col-sm-8">
                        <p class="alert alert-danger text-center">@siteForm.globalError.message</p>
                    </div>
                </div>
            }

                <!-- titulo -->
            @texto(siteForm("titulo"),
                label = "Título:",
                placeholder = "Insira o título")

            @selecao(siteForm("pais"),
                label = "País:",
                optionMap = paises,
                isMultiple = false)

                <!-- url -->
            @texto(siteForm("url"),
                label = "Url:",
                placeholder = "Insira o endereço eletrônico")

            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-12">
                    <button id="btnSalvar" type="submit" class="btn btn-success">Salvar</button>
                    <a class="btn btn-default" type="button" href="@routes.SiteController.telaLista()">Cancelar</a>
                </div>
            </div>
        }
        </div>
    </div>
</div>

}

我的控制器:

@Security.Authenticated(SecuredAdmin.class)
public Result inserir(Long id) {

    SiteFormData siteData = (id == 0) ? new SiteFormData() : models.Site.makeSiteFormData(id);

    //Resgata os dados do formulario atraves de uma requisicao e realiza a validacao dos campos
    Form<SiteFormData> formData = Form.form(SiteFormData.class).bindFromRequest();

    //se existir erros nos campos do formulario retorne o SiteFormData com os erros
    if (formData.hasErrors()) {
        formData.reject("Existem erros no formulário");
        return badRequest(views.html.admin.sites.create.render(formData, Pais.makePaisMap(siteData)));
    } else {
        try {
            //Converte os dados do formularios para uma instancia do Site
            Site site = Site.makeInstance(formData.get());

            //faz uma busca na base de dados do site
            Site siteBusca = Ebean.find(Site.class).where().eq("titulo", formData.data().get("titulo")).findUnique();

            if (siteBusca != null) {
                formData.reject("O Site com o título'" + siteBusca.getTitulo() + "' já esta Cadastrado!");
                return badRequest(views.html.admin.sites.create.render(formData, Pais.makePaisMap(siteData)));
            }

            site.setDataCadastro(new Date());
            site.save();

            tipoMensagem = "success";
            mensagem = "Site '" + site.getTitulo() + "' cadastrado com sucesso.";
            return created(views.html.mensagens.site.mensagens.render(mensagem,tipoMensagem));
        } catch (Exception e) {
            Logger.error(e.getMessage());
            formData.reject("Erro interno de Sistema. Descrição: " + e);
            return badRequest(views.html.admin.sites.create.render(formData, Pais.makePaisMap(siteData)));

        }

    }
}

我的路线:

POST    /admin/site    controllers.SiteController.inserir(id: Long ?= 0)

记录apache-tomcat:

17-Feb-2017 12:40:46.215 WARNING [ajp-apr-8009-exec-153] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [biblioteca-1.0-SNAPSHOT] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
17-Feb-2017 12:40:46.216 WARNING [ajp-apr-8009-exec-153] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [biblioteca-1.0-SNAPSHOT] appears to have started a thread named [Timer-8] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.lang.Object.wait(Object.java:502)
 java.util.TimerThread.mainLoop(Timer.java:526)
 java.util.TimerThread.run(Timer.java:505)

记录postgresql

2017-02-20 12:40:28 UTC [970-2] LOG:  received fast shutdown request
2017-02-20 12:40:28 UTC [970-3] LOG:  aborting any active transactions
2017-02-20 12:40:28 UTC [1013-2] LOG:  autovacuum launcher shutting down
2017-02-20 12:40:28 UTC [10683-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10657-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10673-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10671-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10669-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10667-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10665-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10663-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10659-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [10661-1] postgres@bibliotecadb FATAL:  terminating connection due to administrator command
2017-02-20 12:40:28 UTC [1010-1] LOG:  shutting down
2017-02-20 12:40:28 UTC [1010-2] LOG:  database system is shut down
2017-02-20 12:42:39 UTC [1008-1] LOG:  database system was shut down at 2017-02-20 12:40:28 UTC
2017-02-20 12:42:39 UTC [1008-2] LOG:  MultiXact member wraparound protections are now enabled
2017-02-20 12:42:39 UTC [970-1] LOG:  database system is ready to accept connections
2017-02-20 12:42:39 UTC [1012-1] LOG:  autovacuum launcher started
2017-02-20 12:42:40 UTC [1035-1] [unknown]@[unknown] LOG:  incomplete startup packet

是否需要配置?

0 个答案:

没有答案