0

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?

  • post the full logs & relevant code, for some reason your application is stopping – petey Feb 17 '17 at 15:09
  • The application does not stop only does not respond to POST requests, I will add a code from my controller – Haroldo Ramirez Feb 17 '17 at 15:17
  • User: user@email.com, password 123, Testing address: http://104.154.131.204/biblioteca-1.0-SNAPSHOT/#/ – Haroldo Ramirez Feb 17 '17 at 15:29
  • Full log address: https://dl.dropboxusercontent.com/u/78530432/Log%20Apache%20GAE%202017-02-17 – Haroldo Ramirez Feb 17 '17 at 15:37
  • I believe this previous question should help you, http://stackoverflow.com/q/3320400/794088 (found by googling your error line about JDBC driver) – petey Feb 17 '17 at 15:53
  • I see this question, I need to code my ServletContextListener? Or try update my connector jdbc4? Sorry for ignorance but I'm lost on this subject – Haroldo Ramirez Feb 17 '17 at 17:32
  • You say this only happens on persistence operations and data saving? Well, how does your local db setup differ from your cloud? When you have this working on your own machine are you connecting to the same DB as your Google cloud instance? – Usman Mutawakil Feb 17 '17 at 18:14
  • On my local computer I create a postgresql database and make my application connect to it, this same configuration is done on the google cloud server. The same connector, user and password. – Haroldo Ramirez Feb 17 '17 at 18:57
  • Did you see some of these logs locally? How is your connection pool configured? Did the user has database write permissions on Google Cloud Platform? Can you use a more verbose log level (maybe debug) so that we can have more information? – marcospereira Feb 17 '17 at 19:51
  • Guys, I'm going through parts to see which solution will solve the problem. In the Petey message, I've been analyzing this question, when the .war file is deployed in /WEB-INF/lib, a postgresql file is found. I stop tomcat services, I cut this file and add it to the /lib folder of apache-tomcat and reboot tomcat server but problem still persists. – Haroldo Ramirez Feb 20 '17 at 15:53
  • I found the tentative solution to the problem. There are some settings that should be made when the .war file is created, one of them is build.sbt where I changed the servlet container version configuration to: Play2WarKeys.servletVersion: = "3.1" for Play2WarKeys.servletVersion: = "2.5" and it worked. According to the play2-war-plugin: 3.1 is recommended for apache-tomcat version 8 and 2.5 for version 6. Link for the plugin: https://github.com/play2war/play2-war-plugin – Haroldo Ramirez Feb 22 '17 at 19:40

0 Answers0