Java,Glassfish,连接已关闭

时间:2017-06-27 01:40:27

标签: java glassfish-4

我正面临Payara服务器4.1.1.164的问题。

在日志中,我发现错误连接首先重置,然后所有连接都无法使用错误连接已关闭。

我需要重新启动我的应用程序以恢复所有内容,如果不这样做,连接将不会重建。

以下是调用堆栈,抱歉我必须隐藏查询。

我怎样才能重播此错误或如何避免相同的错误?

domain.xml中

<jdbc-connection-pool match-connections="true" validate-atmost-once-period-in-seconds="60" connection-creation-retry-attempts="15" statement-leak-reclaim="true" validation-table-name="dbo.UBConnectionTest" res-type="javax.sql.ConnectionPoolDataSource" connection-creation-retry-interval-in-seconds="6" max-pool-size="30" max-wait-time-in-millis="30000" datasource-classname="com.microsoft.sqlserver.jdbc.SQLServerXADataSource" idle-timeout-in-seconds="1500" name="xxxxxPool" is-connection-validation-required="true" init-sql="select 1 from UBConnectionTest">
  <property name="serverName" value="xxxxx.xxxxx.xxxx.xxx"></property>
  <property name="portNumber" value="1433"></property>
  <property name="databaseName" value="xxxx"></property>
  <property name="user" value="xxxx"></property>
  <property name="password" value="xxxxxxxx"></property>
  <property name="encrypt" value="true"></property>
  <property name="url" value="jdbc:sqlserver://xxxx.xxxxx.xxxx.xxxx:1433;database=xxxxx;user=xxxxx;password=xxxxxxxx;encrypt=true;hostNameInCertificate=*.xxx.xxxx.xxxx;loginTimeout=30;trustServerCertificate=true;"></property>
</jdbc-connection-pool>


 [#|2017-06-06T05:40:53.597+0000|INFO|Payara 4.1|org.eclipse.persistence.session./file:/opt/payara41/glassfish/domains/domain1/applications/HEMPlatform-ear/HEMPlatform-ejb_jar/_HEMPlatformFNDPU.query|_ThreadID=25;_ThreadName=http-thread-pool(1);_TimeMillis=1496727653597;_LevelValue=800;|
   Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DatabaseException
 Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset


 [#|2017-06-06T05:40:53.597+0000|INFO|Payara 4.1|org.eclipse.persistence.session./file:/opt/payara41/glassfish/domains/domain1/applications/HEMPlatform-ear/HEMPlatform-ejb_jar/_HEMPlatformFNDPU.query|_ThreadID=25;_ThreadName=http-thread-pool(1);_TimeMillis=1496727653597;_LevelValue=800;|
   Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DatabaseException
 Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset
 Error Code: 0
 Call: SELECT xxxxxx))
    bind => [2 parameters bound]
 Query: ReadAllQuery(name="xxxxx))").|#]

 [#|2017-06-06T05:40:53.598+0000|INFO|Payara 4.1|org.eclipse.persistence.session./file:/opt/payara41/glassfish/domains/domain1/applications/HEMPlatform-ear/HEMPlatform-ejb_jar/_HEMPlatformFNDPU.query|_ThreadID=25;_ThreadName=http-thread-pool(1);_TimeMillis=1496727653598;_LevelValue=800;|
   Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DatabaseException
 Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
 Error Code: 0
 Call: xxxxxx))
    bind => [2 parameters bound]
 Query: ReadAllQuery(name="xxxxxxxxxx)").|#]

 [#|2017-06-06T05:40:56.320+0000|INFO|Payara 4.1|com.hand.glassfish.security.oauth2.OAuth2AuthModule|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656320;_LevelValue=800;|
   token is Bearer 2fb378a7-2a33-3986-a288-35c97d358bac,userPrincipal is :null,remoteName is null|#]

 [#|2017-06-06T05:40:56.321+0000|INFO|Payara 4.1|com.hand.glassfish.security.oauth2.OAuth2AuthModule|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656321;_LevelValue=800;|
   token is Bearer 2fb378a7-2a33-3986-a288-35c97d358bac|#]

 [#|2017-06-06T05:40:56.321+0000|INFO|Payara 4.1|com.hand.glassfish.security.oauth2.OAuth2AuthModule|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656321;_LevelValue=800;|
   requestToke is 2fb378a7-2a33-3986-a288-35c97d358bac,sessionToken is 2fb378a7-2a33-3986-a288-35c97d358bac|#]

 [#|2017-06-06T05:40:56.321+0000|INFO|Payara 4.1|com.hand.glassfish.security.oauth2.OAuth2AuthModule|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656321;_LevelValue=800;|
   requestToken is same from the sessionToke|#]

 [#|2017-06-06T05:40:56.321+0000|INFO|Payara 4.1|com.hand.glassfish.security.oauth2.OAuth2AuthModule|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656321;_LevelValue=800;|
   after deal the defaultGroup length is 3|#]

 [#|2017-06-06T05:40:56.321+0000|INFO|Payara 4.1|com.hand.glassfish.security.oauth2.OAuth2AuthModule|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656321;_LevelValue=800;|
   after deal the defaultGroup token is 2fb378a7-2a33-3986-a288-35c97d358bac|#]

 [#|2017-06-06T05:40:56.322+0000|INFO|Payara 4.1|org.eclipse.persistence.session./file:/opt/payara41/glassfish/domains/domain1/applications/HEMPlatform-ear/HEMPlatform-ejb_jar/_HEMPlatformFNDPU.query|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656322;_LevelValue=800;|
   Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DatabaseException
 Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
 Error Code: 0
 Call: xxxxxxxxx)
    bind => [2 parameters bound]
 Query: ReadAllQuery(name=xxxxxxx").|#]

 [#|2017-06-06T05:40:56.323+0000|INFO|Payara 4.1|org.eclipse.persistence.session./file:/opt/payara41/glassfish/domains/domain1/applications/HEMPlatform-ear/HEMPlatform-ejb_jar/_HEMPlatformFNDPU.query|_ThreadID=27;_ThreadName=http-thread-pool(3);_TimeMillis=1496727656323;_LevelValue=800;|
   Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DatabaseException
 Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
 Error Code: 0
 Call:xxxxxxx))
    bind => [2 parameters bound]
 Query: ReadAllQuery(name="xxxxxxxxxxxx)").|#]

[#|2017-06-06T05:40:58.596+0000|INFO|Payara 4.1|org.eclipse.persistence.session./file:/opt/payara41/glassfish/domains/domain1/applications/HEMPlatform-ear/HEMPlatform-ejb_jar/_HEMPlatformFNDPU.query|_ThreadID=25;_ThreadName=http-thread-pool(1);_TimeMillis=1496727658596;_LevelValue=800;|
  Communication failure detected when attempting to perform read query outside of a transaction. Attempting to retry query. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.3.qualifier): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.

2 个答案:

答案 0 :(得分:0)

该消息是由于数据层(JDBC)中的套接字连接出错而引起的。如果连接池在应用程序服务器中具有可靠的连接数,请查看连接池,如果使用SSL,请检查应用程序服务器和数据库服务器中的TLS版本。

答案 1 :(得分:0)

为避免在GlassFish中遇到JDBC连接失败,首先,您可以增加连接池超时。我认为您的数据库非常繁忙,无法在特定时间内响应GlassFish请求,因此无法正确处理您的连接。确保您的数据库服务器正在运行,并且您有足够的资源(RAM,CPU,连接)。

其次,您可以在使用之前验证连接池,也可以在连接池中进行配置。

使用资源&gt;下的管理控制台设置JDBC连接池属性JDBC&gt;连接池&gt;缓冲池名称

超时设置 有两种超时设置:   - 最长等待时间。  - 空闲超时。

连接验证设置 如果为true,则池在将连接提供给应用程序之前验证连接(检查以确定它们是否可用)。但是,缺点是,要求连接验证强制服务器在每次池返回连接时应用验证算法,这会增加getConnection()

的延迟的开销。