thank you Stian.
I have found my error. I was using a JTA transaction provider and changed
that to a local one and it is now working.
Just in case anyone is interested this is how my persistence.xml is :
<?xml version="1.0" encoding="UTF-8"?>
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<!-- Set jboss.as.jpa.managed to false to disable container
managed JPA access to the persistence unit -->
And this how i create my entity manager to handle the transaction :
EntityManagerFactory emf =
EntityManager em = emf.createEntityManager();
// some code to save data to the db
On Fri, Nov 28, 2014 at 11:10 AM, Stian Thorgersen <stian(a)redhat.com> wrote:
No, there's no example for this, but you can look at the Keycloak
as we use JPA ourselves.
You have two options:
a) Shared EntityManager instance with internal Keycloak providers - if
you're using the same db for both this is a good option
b) Separate EntityManager instance
For option a) you should look at extending the default connectionJpa
provider to add your own persistence.xml (you need to copy/modify
Keycloak's persistence.xml). Look at
For option b) you can just have your ProviderFactory create the
EntityManagerFactory and pass it to the Provider instance. For this you
only need to look at
----- Original Message -----
> From: "Alexander Chriztopher" <alexander.chriztopher(a)gmail.com>
> To: "Stian Thorgersen" <stian(a)redhat.com>
> Cc: keycloak-user(a)lists.jboss.org
> Sent: Friday, 28 November, 2014 11:01:46 AM
> Subject: Re: [keycloak-user] Providers with CDI
> ok ! Are there any examples of using JPA ?
> On Fri, Nov 28, 2014 at 10:54 AM, Stian Thorgersen <stian(a)redhat.com>
> > No, afraid we don't support CDI (or any other managed features such as
> > EJBs) in our providers. They are just POJO's and Keycloak manages their
> > life-cycle.
> > In the future we may make it simpler to create providers, but this is
> > a priority atm.
> > ----- Original Message -----
> > > From: "Alexander Chriztopher"
> > > To: keycloak-user(a)lists.jboss.org
> > > Sent: Friday, 28 November, 2014 10:14:32 AM
> > > Subject: [keycloak-user] Providers with CDI
> > >
> > > Hi All,
> > >
> > > I there a way to get providers to be managed by CDI.
> > >
> > > The aim is to get access to services such as entity manager
> > > lifecycle management which would be done manually today.
> > >
> > > Thanks for any help.
> > >
> > > _______________________________________________
> > > keycloak-user mailing list
> > > keycloak-user(a)lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/keycloak-user