<div dir="ltr">This is in relation to my last submission.  It seems the following line in JpaModelProvider.java is not compatible with container managed JTA transactions? <div><br></div><div>line: 26   EntityManagerFactory emf = Persistence.createEntityManagerFactory(&quot;jpa-keycloak-identity-store&quot;, getHibernateProperties());<br>
<br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Dean Peterson</b> <span dir="ltr">&lt;<a href="mailto:peterson.dean@gmail.com">peterson.dean@gmail.com</a>&gt;</span><br>
Date: Thu, Mar 13, 2014 at 1:40 PM<br>Subject: Trying to use JTA transactions for JPA causes errors<br>To: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br><br><br><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">I get transaction rollback errors frequently.  Every time I leave the application idle for a few minutes and come back, the system has transaction errors.  I have to refresh multiple times for the keycloak admun-ui to start responding again.  I realized my settings were using local database transactions and that does not work well.  I am using JBOSS and J2EE so I definitely want to use the container managed transactions.  I switched the settings in my management console and changed my persistence.xml to this:</span><div style="font-family:arial,sans-serif;font-size:13px">

<br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>&lt;persistence xmlns=&quot;<a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a>&quot;</div><div>

    xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;</div><div>    xsi:schemaLocation=&quot;<a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a> <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;</div>

<div>    version=&quot;1.0&quot;&gt;</div><div>    &lt;persistence-unit name=&quot;jpa-keycloak-identity-store&quot; transaction-type=&quot;JTA&quot;&gt;</div><div>        &lt;jta-data-source&gt;java:jboss/datasources/ui_users&lt;/jta-data-source&gt;</div>

<div>        &lt;class&gt;org.keycloak.models.jpa.entities.ApplicationEntity&lt;/class&gt;</div><div>        &lt;class&gt;org.keycloak.models.jpa.entities.CredentialEntity&lt;/class&gt;</div><div>        &lt;class&gt;org.keycloak.models.jpa.entities.OAuthClientEntity&lt;/class&gt;</div>

<div>        &lt;class&gt;org.keycloak.models.jpa.entities.RealmEntity&lt;/class&gt;</div><div>        &lt;class&gt;org.keycloak.models.jpa.entities.RequiredCredentialEntity&lt;/class&gt;</div><div>        &lt;class&gt;org.keycloak.models.jpa.entities.ApplicationRoleEntity&lt;/class&gt;</div>

<div>        &lt;class&gt;org.keycloak.models.jpa.entities.RealmRoleEntity&lt;/class&gt;</div><div>        &lt;class&gt;org.keycloak.models.jpa.entities.SocialLinkEntity&lt;/class&gt;</div><div>        &lt;class&gt;org.keycloak.models.jpa.entities.UserEntity&lt;/class&gt;</div>

<div>        &lt;class&gt;org.keycloak.models.jpa.entities.UserRoleMappingEntity&lt;/class&gt;</div><div>        &lt;class&gt;org.keycloak.models.jpa.entities.ScopeMappingEntity&lt;/class&gt;</div><div><br></div><div>        &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;</div>

<div><br></div><div>        &lt;properties&gt;</div><div>            </div><div>            &lt;property name=&quot;hibernate.dialect&quot; value=&quot;org.hibernate.dialect.SQLServer2008Dialect&quot;/&gt; </div><div>            &lt;property name=&quot;hibernate.hbm2ddl.auto&quot; value=&quot;update&quot;/&gt;</div>

<div>            </div><div>        &lt;/properties&gt;</div><div>    &lt;/persistence-unit&gt;</div><div>&lt;/persistence&gt;</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><b>Now when I start the server I get the following error:</b></div>

<div><br></div><div><div> java.lang.NullPointerException</div><div><span style="white-space:pre-wrap">        </span>at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:76)</div><div>
<span style="white-space:pre-wrap">        </span>at </div>
<div>.</div><div>.</div><div>.</div><div>org.keycloak.models.jpa.JpaKeycloakSessionFactory.createSession(JpaKeycloakSessionFactory.java:21)</div><div><span style="white-space:pre-wrap">        </span>at </div><div>.</div><div>.</div>

<div>.</div><div>jboss.undertow.deployment.default-server.default-host./auth: Failed to start service</div><div>    Caused by: java.lang.RuntimeException: Failed to construct public org.keycloak.server.KeycloakServerApplication(javax.servlet.ServletContext) throws java.io.FileNotFoundException</div>

</div><div><br></div><div>Any ideas why this is happening?</div><div><br></div><div>Thanks,</div><div><br></div><div>Dean Peterson</div></div></div>
</div><br></div></div>