<div dir="ltr">That makes sense.  I do not necessarily need JTA transactions for keycloak but I am experiencing the error you can see in the keycloak-log.txt constantly.  Without fail, that error occurs when I let keycloak sit idle for about 5 minutes or so.  <div>
<br></div><div>It would be nice to let the container manage connections and transactions to Keycloak still.  Without that, I am fairly certain a production environment needs something like c3p0 or DBCP(Apache Database Connection Pooling) to make the connections to the database stable.  What are your thoughts?  I will try using c3p0 today to see if that fixes the problem in the attached log.  Also, should the jta-data-source tag in the persistence.xml be changed to non-jta-data-source?  The keycloak-server persistence.xml comes with jta-data-source tag out of the box.  I did try changing it to non-jta-data-source and I still get the same errors so that is not the cause of my problem.</div>
<div><br></div><div>Thanks,</div><div><br></div><div>Dean      </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Mar 14, 2014 at 3:53 AM, Stian Thorgersen <span dir="ltr">&lt;<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Keycloak has been designed to work in multiple environments, not just JavaEE. That&#39;s why container managed transactions are not used. JTA transactions are not required either as there&#39;s a single database, hence no need for distributed transactions.<br>

<br>
Can you provide me with some more information about the errors you are seeing? Including the server log, persistence.xml, etc. It should work perfectly well with resource local transactions.<br>
<br>
If you have a real requirement for using JTA a data-source we can certainly look into supporting that.<br>
<div><div class="h5"><br>
----- Original Message -----<br>
&gt; From: &quot;Dean Peterson&quot; &lt;<a href="mailto:peterson.dean@gmail.com">peterson.dean@gmail.com</a>&gt;<br>
&gt; To: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; Sent: Thursday, 13 March, 2014 6:40:23 PM<br>
&gt; Subject: [keycloak-user] Trying to use JTA transactions for JPA causes errors<br>
&gt;<br>
&gt; I get transaction rollback errors frequently. Every time I leave the<br>
&gt; application idle for a few minutes and come back, the system has transaction<br>
&gt; errors. I have to refresh multiple times for the keycloak admun-ui to start<br>
&gt; responding again. I realized my settings were using local database<br>
&gt; transactions and that does not work well. I am using JBOSS and J2EE so I<br>
&gt; definitely want to use the container managed transactions. I switched the<br>
&gt; settings in my management console and changed my persistence.xml to this:<br>
&gt;<br>
&gt; &lt;persistence xmlns=&quot; <a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a> &quot;<br>
&gt; xmlns:xsi=&quot; <a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a> &quot;<br>
&gt; xsi:schemaLocation=&quot; <a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><br>
&gt; <a href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd</a> &quot;<br>
&gt; version=&quot;1.0&quot;&gt;<br>
&gt; &lt;persistence-unit name=&quot;jpa-keycloak-identity-store&quot; transaction-type=&quot;JTA&quot;&gt;<br>
&gt; &lt;jta-data-source&gt;java:jboss/datasources/ui_users&lt;/jta-data-source&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.ApplicationEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.CredentialEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.OAuthClientEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.RealmEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.RequiredCredentialEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.ApplicationRoleEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.RealmRoleEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.SocialLinkEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.UserEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.UserRoleMappingEntity&lt;/class&gt;<br>
&gt; &lt;class&gt;org.keycloak.models.jpa.entities.ScopeMappingEntity&lt;/class&gt;<br>
&gt;<br>
&gt; &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;<br>
&gt;<br>
&gt; &lt;properties&gt;<br>
&gt; &lt;property name=&quot;hibernate.dialect&quot;<br>
&gt; value=&quot;org.hibernate.dialect.SQLServer2008Dialect&quot;/&gt;<br>
&gt; &lt;property name=&quot;hibernate.hbm2ddl.auto&quot; value=&quot;update&quot;/&gt;<br>
&gt; &lt;/properties&gt;<br>
&gt; &lt;/persistence-unit&gt;<br>
&gt; &lt;/persistence&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Now when I start the server I get the following error:<br>
&gt;<br>
&gt; java.lang.NullPointerException<br>
&gt; at<br>
&gt; org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:76)<br>
&gt; at<br>
&gt; .<br>
&gt; .<br>
&gt; .<br>
&gt; org.keycloak.models.jpa.JpaKeycloakSessionFactory.createSession(JpaKeycloakSessionFactory.java:21)<br>
&gt; at<br>
&gt; .<br>
&gt; .<br>
&gt; .<br>
&gt; jboss.undertow.deployment.default-server.default-host./auth: Failed to start<br>
&gt; service<br>
&gt; Caused by: java.lang.RuntimeException: Failed to construct public<br>
&gt; org.keycloak.server.KeycloakServerApplication(javax.servlet.ServletContext)<br>
&gt; throws java.io.FileNotFoundException<br>
&gt;<br>
&gt; Any ideas why this is happening?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Dean Peterson<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; keycloak-user mailing list<br>
&gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</blockquote></div><br></div>