Wine is a software to allow running Windows applications in Linux, MAC etc. platforms. It is available for installation from package managers like yum (RHEL, CentOS) and apt (Ubuntu). You can find more details on how it works in Wine wiki . But the default Wine package available from package manager does not have support for 32 bit Windows applications. This was the case for me. In Redhat Enterprise Linux 7.3, the wine package did not contain support for 32 bit windows applications. So the only option was to build a separate rpm of wine which will include this support. All the steps are executed on a RHEL 7.3 VM (x86_64). Step 1 Download and run shell script which will make wine 64 and 32 support for RHEL: https://github.com/zma/usefulscripts/blob/master/script/install-wine-i686-centos7.sh It accepts a version no. as CLI parameter e.g. 2.0.3 The script installs wine in /usr/local/ directory by default. We can verify the files that are being copied for wine using "
This problem has been faced by many of the developers but the fix is not very common. I had to do some research to find out the problem and solve it.
You have to add a new file in your classpath called c3p0.properties. The file contains -If you are using a MySQL server, the default connection timeout is 8 hours (tested on MySQL 5.2). This causes a problem in production environment as the database could not be connected overnight. Below is the log trace of the problem -
org.hibernate.util.JDBCExceptionReporter: The last packet successfully received from the server was 56697 seconds ago. The last packet sent successfully to the server was 56697 seconds ago, which 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.
As the description says, we can increase the wait_timeout property of MySQL server but it is not a good idea to keep stale connections open for long time. The 'autoReconnect=true' property did not work for me.
I figured out the below solution which worked perfectly for me.
First we need to modify our hibernate.cfg.xml file and add the following lines -
org.hibernate.util.JDBCExceptionReporter: The last packet successfully received from the server was 56697 seconds ago. The last packet sent successfully to the server was 56697 seconds ago, which 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.
As the description says, we can increase the wait_timeout property of MySQL server but it is not a good idea to keep stale connections open for long time. The 'autoReconnect=true' property did not work for me.
I figured out the below solution which worked perfectly for me.
First we need to modify our hibernate.cfg.xml file and add the following lines -
c3p0.testConnectionOnCheckout=true
The last but most important part is to add the required jars in the classpath. You must have hibernate.jar (contains org.hibernate.connection.C3P0ConnectionProvider class) and c3p0.jar.
This should solve the auto disconnection issue permanently.
P.S. To test the fix, you can change the wait_timeout property in my.cnf file (/etc/mysql/my.cnf in Linux) of MySQL server. Specify a small timeout value of few minutes.
Hi
ReplyDeleteIts throwing me the following error
149819 [http-8080-5] ERROR org.hibernate.util.JDBCExceptionReporter - com.mchange.v2.c3p0.PoolBackedDataSource@42500667 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@8fda7516 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge13a8ifwcgyn1g4zi4j|13d1402, idleConnectionTestPeriod -> 300, initialPoolSize -> 0, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 100, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 0, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@4e718292 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge13a8ifwcgyn1g4zi4j|ed9f47, jdbcUrl -> jdbc:mysql://127.0.0.1:3306/orpheus, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> true, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge13a8ifwcgyn1g4zi4j|1b2d7df, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
could you please explain me ..how did you handler the hibernate session factory while writing your persistance code logic
In case of a database operation consisting of multiple transactions, I open the session when I start the 1st transaction and keep it alive till the last transaction. After each transaction I flush the session but don't close it. Finally once the lase transaction is over, I close the session.
ReplyDeleteIam using mysql 5.5.Is it solve timeout issue in my project using your solution
ReplyDeleteMr. Money Casino Review | Casino - Dr. Maryland
ReplyDeleteThe 안성 출장마사지 biggest casino bonus that we have 하남 출장안마 reviewed. Play casino 파주 출장샵 games 전주 출장안마 at Mr. Money Casino, including roulette, blackjack and video poker, and receive 동해 출장안마 your
Essential knowledge for developers and database administrators working with Hibernate. It propels us forward, turning challenges into opportunities. Create A Compitition This blog is useful and intersted. software can be installed.
ReplyDeleteGreat and that i have a neat provide: Where To Buy Houses That Need Renovation house renovation business
ReplyDelete