2013-02-22 5 views
1

jax-rs REST 서비스에 문제가 있습니다.매 초마다 REST 서비스가 작동합니다.

서비스가 제대로 작동하지 않습니다. 모든 두 번째 요청 서비스가 나에게 예외를 던져 :

HTTP Status 500 - could not execute query 

type Exception report 

message could not execute query 

description The server encountered an internal error that prevented it from fulfilling this request. 

exception 

org.hibernate.exception.JDBCConnectionException: could not execute query 
    org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74) 
    org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) 
    org.hibernate.loader.Loader.doList(Loader.java:2147) 
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028) 
    org.hibernate.loader.Loader.list(Loader.java:2023) 
    org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95) 
    org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) 
    org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) 
    com.fit.utilities.BaseDAO.getAll_fetchEager(BaseDAO.java:62) 
    com.fit.utilities.BaseDAO.getAll(BaseDAO.java:37) 
    com.fit.servis.Korisnik_servis.PronadjiPrijatelje(Korisnik_servis.java:174) 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    java.lang.reflect.Method.invoke(Unknown Source) 
    com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) 
    com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) 
    com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) 
    com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353) 
    com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
root cause 

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver. 
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    java.lang.reflect.Constructor.newInstance(Unknown Source) 
    com.mysql.jdbc.Util.handleNewInstance(Util.java:409) 
    com.mysql.jdbc.Util.getInstance(Util.java:384) 
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015) 
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989) 
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984) 
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929) 
    com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1204) 
    com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1191) 
    com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4276) 
    com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4242) 
    org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497) 
    org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415) 
    org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139) 
    org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1560) 
    org.hibernate.loader.Loader.doQuery(Loader.java:661) 
    org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) 
    org.hibernate.loader.Loader.doList(Loader.java:2144) 
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028) 
    org.hibernate.loader.Loader.list(Loader.java:2023) 
    org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95) 
    org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) 
    org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) 
    com.fit.utilities.BaseDAO.getAll_fetchEager(BaseDAO.java:62) 
    com.fit.utilities.BaseDAO.getAll(BaseDAO.java:37) 
    com.fit.servis.Korisnik_servis.PronadjiPrijatelje(Korisnik_servis.java:174) 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    java.lang.reflect.Method.invoke(Unknown Source) 
    com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) 
    com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) 
    com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) 
    com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353) 
    com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
root cause 

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 22.477.953 milliseconds ago. The last packet sent successfully to the server was 22.478.000 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. 
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    java.lang.reflect.Constructor.newInstance(Unknown Source) 
    com.mysql.jdbc.Util.handleNewInstance(Util.java:409) 
    com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1122) 
    com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3317) 
    com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1941) 
    com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114) 
    com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2696) 
    com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2105) 
    com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2264) 
    org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) 
    org.hibernate.loader.Loader.getResultSet(Loader.java:1668) 
    org.hibernate.loader.Loader.doQuery(Loader.java:662) 
    org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) 
    org.hibernate.loader.Loader.doList(Loader.java:2144) 
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028) 
    org.hibernate.loader.Loader.list(Loader.java:2023) 
    org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95) 
    org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) 
    org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) 
    com.fit.utilities.BaseDAO.getAll_fetchEager(BaseDAO.java:62) 
    com.fit.utilities.BaseDAO.getAll(BaseDAO.java:37) 
    com.fit.servis.Korisnik_servis.Login(Korisnik_servis.java:32) 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    java.lang.reflect.Method.invoke(Unknown Source) 
    com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) 
    com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) 
    com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) 
    com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353) 
    com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
root cause 

java.net.SocketException: Software caused connection abort: socket write error 
    java.net.SocketOutputStream.socketWrite0(Native Method) 
    java.net.SocketOutputStream.socketWrite(Unknown Source) 
    java.net.SocketOutputStream.write(Unknown Source) 
    java.io.BufferedOutputStream.flushBuffer(Unknown Source) 
    java.io.BufferedOutputStream.flush(Unknown Source) 
    com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3298) 
    com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1941) 
    com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114) 
    com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2696) 
    com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2105) 
    com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2264) 
    org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) 
    org.hibernate.loader.Loader.getResultSet(Loader.java:1668) 
    org.hibernate.loader.Loader.doQuery(Loader.java:662) 
    org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) 
    org.hibernate.loader.Loader.doList(Loader.java:2144) 
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028) 
    org.hibernate.loader.Loader.list(Loader.java:2023) 
    org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95) 
    org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) 
    org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) 
    com.fit.utilities.BaseDAO.getAll_fetchEager(BaseDAO.java:62) 
    com.fit.utilities.BaseDAO.getAll(BaseDAO.java:37) 
    com.fit.servis.Korisnik_servis.Login(Korisnik_servis.java:32) 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    java.lang.reflect.Method.invoke(Unknown Source) 
    com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) 
    com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) 
    com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) 
    com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) 
    com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
    com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353) 
    com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.32 logs. 

Apache Tomcat/7.0.32 

서비스 JSON..I이 문제가 크기 바이트 문자열 때문이라고 생각 검색 할 수 있습니다. 성공의

예 검색 :

example

어떻게이 문제를 해결하려면?

+1

이것은 REST 또는 JAX-WS의 잘못된 태깅과 아무 관련이 없습니다. 이것은 데이터 계층 문제입니다. 연결을 오래 유지하기 위해 MySQL의 타임 아웃 설정에서 작업해야합니다. – kolossus

답변

1

문제점은 mysql 데이터 소스 구성에 있습니다. 이 두 매개 변수를 데이터 소스 정의에 추가하십시오.

testOnBorrow="true" validationQuery="select 1" 
+0

고마워요! 이제 완벽하게 작동합니다. :) –

1

나는 이것이 서버 측 문제라고 생각합니다. 그것의 클래스가 명확하게 보이는 클래스 BaseDAOgetAll_fetchEager이 방법에서는 어떤 이유로 인해 실패한 몇 가지 기준 쿼리를 만들고 있습니다. 귀하의 기준 쿼리 문제를 해결하면 해결할 것이라고 확신합니다. 연결 속성이 올바르게 설정되어 있는지 확인하고 데이터베이스에 연결할 수 있습니다.

+0

+1 대답은 ...... –

1

대답은 스택 추적에 있다고 생각합니다.

서버에서 성공적으로받은 마지막 패킷은 22.477.953 밀리 초 전입니다. 서버에 성공적으로 보낸 마지막 패킷은 22.478000 밀리 초 전입니다. 서버 구성 값인 'wait_timeout'보다 깁니다. 응용 프로그램에서 사용하기 전에 연결 유효성을 만료 및/또는 테스트하거나, 클라이언트 시간 초과에 대한 서버 구성 값을 늘리거나 Connector/J 연결 속성 'autoReconnect = true'를 사용하여이 문제를 방지해야합니다.

mysql에 대한 연결이 열려 있지 않으며 자동 다시 연결로 설정되어 있지 않습니다.

+0

+1 대답은 .... –

관련 문제