1. java
  2. android
  3. c#
  4. .net
  5. javascript
  6. php
  7. jquery
  8. html
  9. sql

Error 500. Problemas com Timeout

Olá amigos, minha api ta retornando error 500 quando eu faço duas solicitações "rapidamente". Por exp: fiz um GET em /usuarios e depois faço outro GET em pedidos/

Pelo que lí aqui no stacktrace é problema com timeout mas não sei como resolver, alguem já passou por isso ou sabe resolver?

Grato, VH.

Hibernate:
    /* select
        a
    from
        usuarios a
    where
        a.login=:aLogin */ select
            usuario0_.id as id1_24_,
            usuario0_.create_at as create_a2_24_,
            usuario0_.delete_at as delete_a3_24_,
            usuario0_.update_at as update_a4_24_,
            usuario0_.login as login5_24_,
            usuario0_.nome as nome6_24_,
            usuario0_.senha as senha7_24_,
            usuario0_.status as status8_24_,
            usuario0_.tipo as tipo9_24_
        from
            usuarios usuario0_
        where
            usuario0_.login=?
org.hibernate.exception.JDBCConnectionException: could not prepare statement
org.hibernate.exception.JDBCConnectionException: could not prepare statement
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionEx
ception: could not prepare statement
        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntit
yManagerImpl.java:1763)
        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntit
yManagerImpl.java:1677)
        at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458
)
        at br.com.bracode.abase.dao.UsuarioDAO.findByLogin(UsuarioDAO.java:19)
        at br.com.bracode.abase.dao.UsuarioDAO.autenticaAdmin(UsuarioDAO.java:29
)
        at br.com.bracode.abase.util.AuthInterceptor.intercept(AuthInterceptor.j
ava:43)
        at br.com.bracode.abase.util.AuthInterceptor$Proxy$_$$_WeldClientProxy.i
ntercept(Unknown Source)
        at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToI
nstantiateInterceptorHandler.java:71)
        at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToI
nstantiateInterceptorHandler.java:68)
        at br.com.caelum.vraptor.core.Try.run(Try.java:18)
        at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSaf
ely(ToInstantiateInterceptorHandler.java:68)
        at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(To
InstantiateInterceptorHandler.java:61)
        at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterc
eptorStack.java:83)
        at br.com.caelum.vraptor.core.DefaultInterceptorStack.start(DefaultInter
ceptorStack.java:93)
        at br.com.caelum.vraptor.core.DefaultInterceptorStack$Proxy$_$$_WeldClie
ntProxy.start(Unknown Source)
        at br.com.caelum.vraptor.observer.RequestHandlerObserver.handle(RequestH
andlerObserver.java:93)
        at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpe
cialValue(MethodInjectionPoint.java:93)
        at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.
java:266)
        at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.
java:253)
        at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.jav
a:232)
        at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier
.java:169)
        at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier
.java:165)
        at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifie
r.java:119)
        at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java
:112)
        at org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
        at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:123)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
        at br.com.bracode.abase.util.EntityManagerFilter.doFilter(EntityManagerF
ilter.java:19)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1041)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoin
t.java:315)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.exception.JDBCConnectionException: could not prepare st
atement
        at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQL
ExceptionTypeDelegate.java:65)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.conver
t(StandardSQLExceptionConverter.java:49)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlException
Helper.java:126)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPre
parationTemplate.prepareStatement(StatementPreparerImpl.java:196)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQuery
Statement(StatementPreparerImpl.java:160)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1885)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1839)
        at org.hibernate.loader.Loader.doQuery(Loader.java:910)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:355)
        at org.hibernate.loader.Loader.doList(Loader.java:2554)
        at org.hibernate.loader.Loader.doList(Loader.java:2540)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370)
        at org.hibernate.loader.Loader.list(Loader.java:2365)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslat
orImpl.java:387)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.
java:236)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
        at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
        at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
        at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449
)
        ... 45 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
 No operations allowed after connection closed.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.Util.getInstance(Util.java:386)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
        at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(Connecti
onImpl.java:1304)
        at com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1296)
        at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:45
11)
        at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:44
76)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(
StatementPreparerImpl.java:162)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPre
parationTemplate.prepareStatement(StatementPreparerImpl.java:186)
        ... 62 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last pac
ket successfully received from the server was 38,644,428 milliseconds ago.  The
last packet sent successfully to the server was 38,644,428 milliseconds ago. is
longer than the server configured value of 'wait_timeout'. You should consider e
ither expiring and/or testing connection validity before use in your application
, increasing the server configured values for client timeouts, or using the Conn
ector/J connection property 'autoReconnect=true' to avoid this problem.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1
121)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3938)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2551)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2809)
        at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1729)
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doComm
it(JdbcTransaction.java:112)
        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(A
bstractTransactionImpl.java:180)
        at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.jav
a:77)
        at br.com.bracode.abase.util.JPAUtil.commit(JPAUtil.java:51)
        at br.com.bracode.abase.util.EntityManagerFilter.doFilter(EntityManagerF
ilter.java:20)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1041)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoin
t.java:313)
        ... 3 more
Caused by: java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82
)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3919)
        ... 25 more
  • Você está fazendo essas requisições via ajax?

    lucastody   16 de jul de 2015
  • Meus testes eu fiz usando o postman e outro p fazer a requisição... mas em produção vai ser via ajax... Eu acho que é alguma configuração do mysql ou tomcat da máquina. Pq no meu pc de desenvolvimento não enfrento esse problema. O tomcat deve ta configurado diferente ou sei lá, realmente n sei onde possa ser

    Victor Hugo Vieira de Sousa   16 de jul de 2015
  • Pela exception, talvez vc possa tentar usar a opção "autoReconnect=true" e ver se resolve.

    lucastody   16 de jul de 2015
  • hummm onde seria isso?

    Victor Hugo Vieira de Sousa   16 de jul de 2015
  • Coloca na string conexão: mysql://db_user:db_user@localhost/mydb?autoReconnect=true

    lucastody   16 de jul de 2015
Mostrar todos os 6 comentários>
  1. Você vai ver essas setas em qualquer página de pergunta. Com elas, você pode dizer se uma pergunta ou uma resposta foram relevantes ou não.
  2. Edite sua pergunta ou resposta caso queira alterar ou adicionar detalhes.
  3. Caso haja alguma dúvida sobre a pergunta, adicione um comentário. O espaço de respostas deve ser utilizado apenas para responder a pergunta.
  4. Se o autor da pergunta marcar uma resposta como solucionada, esta marca aparecerá.
  5. Clique aqui para mais detalhes sobre o funcionamento do GUJ!

1 resposta

Não é a resposta que estava procurando? Procure outras perguntas com as tags mysql tomcat jdbc java vraptor ou faça a sua própria pergunta.