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:
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="jpa-keycloak-identity-store"
transaction-type="JTA">
<jta-data-source>java:jboss/datasources/ui_users</jta-data-source>
<class>org.keycloak.models.jpa.entities.ApplicationEntity</class>
<class>org.keycloak.models.jpa.entities.CredentialEntity</class>
<class>org.keycloak.models.jpa.entities.OAuthClientEntity</class>
<class>org.keycloak.models.jpa.entities.RealmEntity</class>
<class>org.keycloak.models.jpa.entities.RequiredCredentialEntity</class>
<class>org.keycloak.models.jpa.entities.ApplicationRoleEntity</class>
<class>org.keycloak.models.jpa.entities.RealmRoleEntity</class>
<class>org.keycloak.models.jpa.entities.SocialLinkEntity</class>
<class>org.keycloak.models.jpa.entities.UserEntity</class>
<class>org.keycloak.models.jpa.entities.UserRoleMappingEntity</class>
<class>org.keycloak.models.jpa.entities.ScopeMappingEntity</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServer2008Dialect"/>
<property name="hibernate.hbm2ddl.auto"
value="update"/>
</properties>
</persistence-unit>
</persistence>
*Now when I start the server I get the following error:*
java.lang.NullPointerException
at
org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:76)
at
.
.
.
org.keycloak.models.jpa.JpaKeycloakSessionFactory.createSession(JpaKeycloakSessionFactory.java:21)
at
.
.
.
jboss.undertow.deployment.default-server.default-host./auth: Failed to
start service
Caused by: java.lang.RuntimeException: Failed to construct public
org.keycloak.server.KeycloakServerApplication(javax.servlet.ServletContext)
throws java.io.FileNotFoundException
Any ideas why this is happening?
Thanks,
Dean Peterson