Java ,Glassfish ,The connection is closed - java

I'm facing an issue with Payara server 4.1.1.164.
In the log, I found error Connection reset first, then all the connection became not available with error The connection is closed.
I need to restart my application to get everything back, the connection won't rebuild if i don't.
The following is the call stack, sorry I have to hide the query.
How could I replay this error or how to avoid the same?
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.

that message is caused because something is wrong in the socket connection in data layer (JDBC). Please have a look in your connection pool if it has a confortable number of available connections in the application server, and also check, if you are using SSL, the TLS version in the application server and in the database server.

To avoid encountering JDBC connection failure in GlassFish, first things first, you can increase the connection pool timeout. I think your DB is extremely busy and is not able to response GlassFish request within the specific time, as a result, your connection can not be handled properly. Make sure your DB server is running and you have enough resources (RAM, CPU, connection).
Secondly, You can validate connection pool before using it which can be configured in connection pool as well.
Set JDBC Connection Pool attributes with the Admin Console under Resources > JDBC > Connection Pools > PoolName.
Timeout Settings
There are two timeout settings:
- Max Wait Time.
- Idle Timeout.
Connection Validation Settings
If true, the pool validates connections (checks to find out if they are usable) before providing them to an application. However, the disadvantage is, requiring connection validation forces the server to apply the validation algorithm every time the pool returns a connection, which adds overhead to the latency of getConnection()

Related

how to fix Keystore was tampered with, or password was incorrect on glassfish server

i'm trying to create a connection pool and JDBC Resource to deploy a java application on glassfish server, however, I couldn't deploy the project, and this is what it said:
Error occurred during deployment: Exception while preparing the app :
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: Error in allocating a connection.
Cause: The connection could not be allocated: Cannot open
file:C:\Users\nguye\GlassFish_Server500\glassfish\domains\domain1/config/keystore.jks
[Keystore was tampered with, or password was incorrect] Error Code: 0.
Please see server.log for more details.
Just try adding
?autoReconnect=true&useSSL=false to you database on NetBeans as well as on connection pool URL.

How do I resolve mssql resetting connections

I keep getting this error randomly when I test an application with mssql and don't have an idea of what I can do to correct the issue.
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException:
Connection reset ClientConnectionId:a2fb508d-0e8e-48b0-92ed-2d1f262b4db1 Error Code: 0
My setup consists of
Eclipselink as the ORM
sqljdbc v4.1
sql server 2014
Java 8
I believe the problem is probably a setting within sql-server though I haven't seen anything that I could correct. The application works perfect on postgres and mysql but the customer only wants to use mssql.
MSFT JDBC drivers do not call the sp_reset_connection procedure used to cleanup from the previous session.
I am thinking that this error is coming from something left hanging that is being cleaned up with the other databases.
You will need to run a SQL Profile trace on all the connections until the error occurs to see the actual cause.
More can be found at :
What does "exec sp_reset_connection" mean in Sql Server Profiler?

Java EE Web Application Glassfish error database not found

I am working on what is basically my first Java Enterprise-project following this video (source) tutorial. I have the exact same code as the guy in the video, but when trying to run my project I get this error code in the Glassfish server log:
Allvarlig: Exception while deploying the app [CRUDWebApplication] :
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a
connection. Cause: Connection could not be allocated because: The
connection was refused because the database studentDB was not found.
Error Code: 0
So the problem is that the database studentDB can't be found and I cannot seem to figure out what may be the cause of this...

project not geting deployed in glassfish server

i am trying to debug my project but its showing error message as such :
"cannot Deploy WebForm
Deployment Error for module: WebForm: Error occurred during deployment: Exception while preparing the app : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
Error Code: 0."
i have done every possible step with the persistence.xml as well as the JPA tables but still it's not deploying.
Help!
You have some sort of DB-connection configured in your app. The message "Error connecting to server localhost on port 1527 with message Connection refused: connect. Error Code: 0" says, your program tries to reach a DB on port 1527. The possibilities are:
on the production server is no DB running: install and configure DB
the program does not have the rights to access DB
the DB-connection on production-server is reached differently than in development - adjust your configuration

I can not connect database from Netbeans

I have a MySQL database on internet. I can reach it by browser and MySQL Workbench successfully. I added database to Netbeans. When I tried to connect database from Netbeans I get this error:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
Error code 0, SQL state 08S01: Communications link failure
The last packet successfully received from the server was 14.047 milliseconds ago. The last packet sent successfully to the server was 1 milliseconds ago.
I also tried to connect database by using restful web service. I get this error:
GET RequestFailed RequestFailed --> Status: (500)
Response: {
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Error Code: 0
Call: SELECT o_id, isim, not, yas FROM ogrenci
Query: ReadAllQuery(referenceClass=Ogrenci sql="SELECT o_id, isim, not, yas FROM ogrenci")
root cause
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Error Code: 0
Call: SELECT o_id, isim, not, yas FROM ogrenci
Query: ReadAllQuery(referenceClass=Ogrenci sql="SELECT o_id, isim, not, yas FROM ogrenci")
root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
root cause
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 228.471 milliseconds ago. The last packet sent successfully to the server was 11 milliseconds ago.
root cause
java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
Try to increase the wait_timeout mysql variable:
SET wait_timeout=300;

Categories

Resources