0

I've this project: https://github.com/AndreaCatania/libreria

I've deployed this project into WildFly 8.2 and when it get outage of the DB connections the AS can not reconnects automatically, and the application is freezed (I have to restart AS).

If I deploy the same project into GlassFish i've no problem.

How can I resolve this issue?

WildFly configuration:

https://github.com/AndreaCatania/libreria/blob/master/standalone-full.xml

https://github.com/AndreaCatania/libreria/blob/master/standalone.xml

Andrea Catania
  • 1,361
  • 3
  • 21
  • 37
  • Can we see the `stanalone.xml` or `standalone-full.xml` from `%JBOSS_HOME%/standalone/configuration/`? – Boris Pavlović Mar 11 '15 at 09:56
  • Yes of course https://github.com/AndreaCatania/libreria/blob/master/standalone.xml - https://github.com/AndreaCatania/libreria/blob/master/standalone-full.xml – Andrea Catania Mar 11 '15 at 10:40
  • I can see that you're using the default H2 database and wondering how it can go offline... – Boris Pavlović Mar 11 '15 at 10:46
  • Hmmm I've not understand, what do you mean? – Andrea Catania Mar 11 '15 at 10:55
  • Aah, sorry, you leave hibernate managing the database connection. It's not managed by the container. Okay, so what's the exception thrown by the app deployed on wildfly? – Boris Pavlović Mar 11 '15 at 12:19
  • The problem is this, i've no exception on StackTrace... When I Hold "CTRL+R" for 2 sec to shoot requests to the servlet that use the DB connection the application becoming freezed. When I do the same thing with APP deployed on GlassFish I've no problem, the APP never becoming frezed. After a while the APP is freezed on WildFly I get this: ARJUNA012117: TransactionReaper::check timeout for TX 0:ffff7f000001:6a4e795e:54fff1ff:6a in state RUN – Andrea Catania Mar 11 '15 at 12:31
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/72772/discussion-between-andrea-catania-and-boris-pavlovic). – Andrea Catania Mar 11 '15 at 15:53

2 Answers2

0

On your hibernate.cfg.xml you can add lines like these:

<property name="hibernate.c3p0.validate">true</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1</property>

Which will validate connections to Database. Taken from https://confluence.atlassian.com/display/CONF43/Surviving+Database+Connection+Closures

alphamikevictor
  • 595
  • 7
  • 17
0

You seem to be using C3P0 which has known problems when the database goes down. You should consider switching to HikariCP which responds better in such situations. Here is an excellent comparison of the various connection pools under database outage.

Alternatively, consider using the pooling functionality provided by the app server.

manish
  • 19,695
  • 5
  • 67
  • 91
  • I tried HikariCP but I have the same problem... can WildFly be the problem? (if you want you can check the git, I've pushed the changes). – Andrea Catania Mar 11 '15 at 22:30
  • Maybe it's time to go to Wildfly Community Forum (https://developer.jboss.org/en/wildfly) and ask the question. – Boris Pavlović Mar 12 '15 at 07:36
  • I think it is a good move to switch to HikariCP. The persistent problem seems to be from the JBoss transaction manager, which from the logs you have shared above seems to be timing out under load. Increase your transaction timeout to a very high value, say, 1 hour and then check. This [thread](http://stackoverflow.com/questions/5826489/why-transactionreapercheck-timeout-for-tx-warning-in-jboss-server-log), and [this](https://developer.jboss.org/thread/176405?tstart=0&_sscc=t) seem to indicate that this is a common problem with JBoss. – manish Mar 12 '15 at 07:44
  • @manish how can I increase transaction timeout? Is a good idea to use GlassFish? – Andrea Catania Mar 12 '15 at 12:13
  • It is generally a good idea to set the transaction timeout globally. I have used JBoss but not Wildfly myself so if Wildfly offers a console of some sort (JBoss has a web console), you should be able to set the timeout in the console. Glassfish is also good and if it works for you, by all means do use it. – manish Mar 12 '15 at 15:57
  • [Here](http://www.mastertheboss.com/jboss-server/jboss-configuration/configuring-transactions-jta-using-jboss-as7-wildfly) is a post that shows how to configure the transaction timeout in `standalone.xml`. – manish Mar 12 '15 at 16:03
  • @manish damnation... mate I've tried to edit transaction timeout from the web console. I've setted to 3600 but the problem remain. I tried JBOSS eap 6.3 but the problem remain... I want use WildFly because I can use OpenShift otherwise I have to choose GF and go for another "hosting", however it's impossible that only I've this problem... – Andrea Catania Mar 12 '15 at 20:00
  • Is there a specific reason why you want to use OpenShift? If it is a free hosting tier you are after, you could sign up for the 12-month free-tier on Amazon AWS and configure it any way you want. – manish Mar 13 '15 at 14:27