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