I developed an application in Play Framework 2.4.10 (Java) to run on apache-tomcat servers.
The .war
file is created using a plugin of the PlayFramework.
I created a local server apache-tomcat and after the deploy to complete the evolutions happens as expected in all cases, presenting no error logs, only the normal processes of logs. All the functionality of the application works without any kind of error, crashes or lags.
The problem appears when I deploy the application to Google Cloud Platform (GAE) servers and others like my company's.
The deploy happens normally but when the user tries to save new information in some cases the server does not respond to the POST request and the browser is waiting for the response from the server. When the user clicks the save button several times the POST process happens saving the data normally not presenting errors.
Other features such as filtering information, logging out, accessing the registration pages, querying, changing, deleting work normally. The error only occurs when I will update, register or authenticate in the system.
The record screens are made with the templates of the HTML PlayFramework itself with a few hints of the Scala language.
This strange problem happens sporadically.
My form 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>
}
My Controller:
@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)));
}
}
}
My route:
POST /admin/site controllers.SiteController.inserir(id: Long ?= 0)
Log 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)
Log 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
Is there any configuration required?