<div dir="ltr">It looks like Keycloak 1.2 supports JBoss Modules. Try creating a module add specifically add <span style="font-size:12.8000001907349px">'javax.persistence.api' and see if that helps.</span><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Tristan</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 24, 2015 at 2:27 PM, Libor Krzyžanek <span dir="ltr"><<a href="mailto:lkrzyzan@redhat.com" target="_blank">lkrzyzan@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi,</div>it’s a jar in providers folder.<div><br></div><div>Does Keycloak 1.2 allows custom providers as a module?<span class=""><br><div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>Thanks,</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Libor Krzyžanek</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://jboss.org" target="_blank">jboss.org</a> Development Team</div>
</div>
<br></span><div><div class="h5"><div><blockquote type="cite"><div>On 24 Aug 2015, at 17:09, Tristan Paddock <<a href="mailto:tristan.paddock@gmail.com" target="_blank">tristan.paddock@gmail.com</a>> wrote:</div><br><div><div dir="ltr">How are you including your jar file? Is it located under 'standalone/configuration/providers'? Or did you create a module? If you created a module be sure to include 'javax.persistence.api' as a dependency. That was an issue I ran into, making sure I included the correct dependencies for my module.<div><br></div><div>Tristan<br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 24, 2015 at 10:33 AM, Libor Krzyžanek <span dir="ltr"><<a href="mailto:lkrzyzan@redhat.com" target="_blank">lkrzyzan@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi there,<div>within my listener factory's postInit method I’m creating a separate thread that needs to run a sql query by using entity manager from JPA provider.</div><div><br></div><div>In thread I do</div><div>KeycloakModelUtils.runJobInTransaction(sessionFactory, new KeycloakSessionTask() {<br> @Override<br> public void run(KeycloakSession session) {</div><div>…</div><div>EntityManager em = session.getProvider(JpaConnectionProvider.class).getEntityManager();<br></div><div>TypedQuery<UserEntity> query = em.createQuery(<br> "select u from UserEntity u where u.realmId = :realmId order by u.username", UserEntity.class);</div><div><br></div><div><br></div><div>Unfortunately I got java.lang.NoClassDefFoundError: javax/persistence/EntityManager</div><div><br></div><div><br></div><div>I tried to set various class loaders via</div><div>thread.setContextClassLoader(DefaultJpaConnectionProviderFactory.class.getClassLoader());</div><div><br></div><div>but with no success.</div><div><br></div><div>I’m running this on EAP 6.4.</div><div><br></div><div>What is the proper way how to retrieve entity manager for running custom queries?</div><div><div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>Thanks,</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Libor Krzyžanek</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://jboss.org/" target="_blank">jboss.org</a> Development Team</div>
</div>
<br></div></div><br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div><br><div><br></div>
</div></div></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Tristan Paddock<br><br><a href="mailto:Tristan.Paddock@gmail.com" target="_blank">Tristan.Paddock@gmail.com</a><br>970.901.9400</div></div>
</div>