<div dir="ltr">See <a href="http://stackoverflow.com/questions/31455450/auto-recover-connections-in-wildfly-8-2-for-oracle-without-using-validate-on-mat">http://stackoverflow.com/questions/31455450/auto-recover-connections-in-wildfly-8-2-for-oracle-without-using-validate-on-mat</a></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 July 2016 at 15:27, Thomas Barcia <span dir="ltr">&lt;<a href="mailto:TBarcia@wfscorp.com" target="_blank">TBarcia@wfscorp.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">I have Keycloak 1.9.8-Final running against an Oracle database and it appears that when the connections are unused for a period of time (usually overnight) Keycloak is unable to open a JDBC connection to the database.  I spoke with the
 DBAs and the database is not closing the connections.  According to the DBAs I need to enable connection validation but I’m not a programmer and can’t find a good example of how it’s done.  Can anyone provide some help with this?  Am I on the right track in
 resolving the issue?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">This is from my standalone-ha.xml:<u></u><u></u></p>
<p class="MsoNormal">&lt;datasource jndi-name=&quot;java:jboss/datasources/KeycloakDS&quot; pool-name=&quot;KeycloakDS&quot; enabled=&quot;true&quot; use-java-context=&quot;true&quot;&gt;<u></u><u></u></p>
<p class="MsoNormal">                 &lt;connection-url&gt;jdbc:oracle:thin:@&lt;servername&gt;:&lt;port&gt;:&lt;databasename&gt;&lt;/connection-url&gt;<u></u><u></u></p>
<p class="MsoNormal">                  &lt;driver&gt;oracle&lt;/driver&gt;<u></u><u></u></p>
<p class="MsoNormal">                 &lt;pool&gt;<u></u><u></u></p>
<p class="MsoNormal">                   &lt;min-pool-size&gt;1&lt;/min-pool-size&gt;<u></u><u></u></p>
<p class="MsoNormal">                   &lt;max-pool-size&gt;5&lt;/max-pool-size&gt;<u></u><u></u></p>
<p class="MsoNormal">                   &lt;prefill&gt;true&lt;/prefill&gt;<u></u><u></u></p>
<p class="MsoNormal">                  &lt;/pool&gt;<u></u><u></u></p>
<p class="MsoNormal">                  &lt;security&gt;<u></u><u></u></p>
<p class="MsoNormal">                   &lt;user-name&gt;&lt;name&gt;&lt;/user-name&gt;<u></u><u></u></p>
<p class="MsoNormal">                   &lt;password&gt;&lt;password&gt;&lt;/password&gt;<u></u><u></u></p>
<p class="MsoNormal">                 &lt;/security&gt;<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">                &lt;/datasource&gt;<u></u><u></u></p>
<p class="MsoNormal">                &lt;drivers&gt;<u></u><u></u></p>
<p class="MsoNormal">                    &lt;driver name=&quot;h2&quot; module=&quot;com.h2database.h2&quot;&gt;<u></u><u></u></p>
<p class="MsoNormal">                        &lt;xa-datasource-class&gt;org.h2.jdbcx.JdbcDataSource&lt;/xa-datasource-class&gt;<u></u><u></u></p>
<p class="MsoNormal">                    &lt;/driver&gt;<u></u><u></u></p>
<p class="MsoNormal">                    &lt;driver name=&quot;oracle&quot; module=&quot;com.oracle&quot;&gt;<u></u><u></u></p>
<p class="MsoNormal">                        &lt;driver-class&gt;oracle.jdbc.driver.OracleDriver&lt;/driver-class&gt;<u></u><u></u></p>
<p class="MsoNormal">                    &lt;/driver&gt;<u></u><u></u></p>
<p class="MsoNormal">                &lt;/drivers&gt;<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">And this is the error:<u></u><u></u></p>
<p class="MsoNormal">2016-07-14 00:13:09,460 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (Timer-2) SQL Error: 0, SQLState: null<u></u><u></u></p>
<p class="MsoNormal">2016-07-14 00:13:09,461 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (Timer-2) javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/KeycloakDS<u></u><u></u></p>
<p class="MsoNormal">2016-07-14 00:13:09,462 ERROR [org.keycloak.services] (Timer-2) KC-SERVICES0089: Failed to run scheduled task ClearExpiredUserSessions: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire
 JDBC Connection<u></u><u></u></p>
<p class="MsoNormal">        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)<u></u><u></u></p>
<p class="MsoNormal">        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)<u></u><u></u></p>
<p class="MsoNormal">        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1700)<u></u><u></u></p>
<p class="MsoNormal">        at org.hibernate.jpa.internal.TransactionImpl.begin(TransactionImpl.java:48)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.connections.jpa.JpaKeycloakTransaction.begin(JpaKeycloakTransaction.java:39)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.DefaultKeycloakTransactionManager.enlist(DefaultKeycloakTransactionManager.java:41)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:70)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:54)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:101)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:51)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:33)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:101)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.models.cache.infinispan.RealmCacheSession.getDelegate(RealmCacheSession.java:161)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.models.cache.infinispan.RealmCacheSession.getRealms(RealmCacheSession.java:424)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.scheduled.ClearExpiredUserSessions.run(ClearExpiredUserSessions.java:33)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner$1.call(ClusterAwareScheduledTaskRunner.java:53)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner$1.call(ClusterAwareScheduledTaskRunner.java:49)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.cluster.infinispan.InfinispanClusterProvider.executeIfNotExecuted(InfinispanClusterProvider.java:90)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner.runTask(ClusterAwareScheduledTaskRunner.java:49)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.services.scheduled.ScheduledTaskRunner.run(ScheduledTaskRunner.java:44)<u></u><u></u></p>
<p class="MsoNormal">        at org.keycloak.timer.basic.BasicTimerProvider$1.run(BasicTimerProvider.java:51)<u></u><u></u></p>
<p class="MsoNormal">        at java.util.TimerThread.mainLoop(Timer.java:555)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b><span style="font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:#365f91">Thomas  Barcia<u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:&quot;Book Antiqua&quot;,&quot;serif&quot;;color:#a6a6a6">Unix Administrator<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:&quot;Book Antiqua&quot;,&quot;serif&quot;;color:#a6a6a6"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:&quot;Book Antiqua&quot;,&quot;serif&quot;;color:#a6a6a6">World Fuel Services Corporation<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:&quot;Book Antiqua&quot;,&quot;serif&quot;;color:#a6a6a6">9800 NW 41st Street|Miami, FL 33178<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:&quot;Book Antiqua&quot;,&quot;serif&quot;;color:#a6a6a6">office: <a href="tel:305.351.4910" value="+13053514910" target="_blank">305.351.4910</a>|email:
</span><span style="font-size:8.0pt;font-family:&quot;Book Antiqua&quot;,&quot;serif&quot;"><a href="mailto:tbarcia@wfscorp.com" target="_blank"><span style="color:blue">tbarcia@wfscorp.com</span></a></span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:#1f497d"><img border="0" width="69" height="40" src="cid:image001.png@01D1DDB1.39F60770" alt="Description: Description: wfs"></span><span style="font-size:12.0pt;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p>*** This communication has been sent from World Fuel Services <br>
Corporation or its subsidiaries or its affiliates for the intended recipient <br>
only and may contain proprietary, confidential or privileged information. <br>
If you are not the intended recipient, any review, disclosure, copying, <br>
use, or distribution of the information included in this communication <br>
and any attachments is strictly prohibited. If you have received this <br>
communication in error, please notify us immediately by replying to this <br>
communication and delete the communication, including any <br>
attachments, from your computer. Electronic communications sent to or <br>
from World Fuel Services Corporation or its subsidiaries or its affiliates <br>
may be monitored for quality assurance and compliance purposes.***</p>

<p></p></div>

<br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div><br></div>