I developed a custom JpaEntityProvider and deployed this as an archive to a running Keycloak instance. The custom entity doesn’t get loaded until I restart the server, because it’s only added to the persistenceUnit upon creation of the EntityManagerFactory, which happens only on boot.
Is there a workaround for this?
Hot deployment of custom EntityProviders doesn’t work. See https://issues.redhat.com/browse/KEYCLOAK-5782
Thanks @xgp. As suggested in the Jira ticket, I solved it by installing the JpaEntityProvider as a module as described in the docs.
In my particular case, I have a separate jar for the JpaEntityProvider only. Because I like hot deploying, I keep my other SPI’s in another jar and deploy them via an ear.
Just leaving this here in case anyone encounters similar problems.
The custom Entities were detected, but not loaded in the persistence unit, resulting in “Not An Entity” exceptions when querying the custom Entities.
Cause: the @Entity annotation was ignored on module load
Solution: add javax.persistance.api and org.hibernate to the module’s dependencies in your module.xml:
<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="my.company.keycloak.jpaentity">
And of course don’t forget to add it in the standalone.xml: