<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi,</div>it’s a jar in providers folder.<div class=""><br class=""></div><div class="">Does Keycloak 1.2 allows custom providers as a module?<br class=""><div class="">
<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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://jboss.org" class="">jboss.org</a> Development Team</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 24 Aug 2015, at 17:09, Tristan Paddock <<a href="mailto:tristan.paddock@gmail.com" class="">tristan.paddock@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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 class=""><br class=""></div><div class="">Tristan<br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Aug 24, 2015 at 10:33 AM, Libor Krzyžanek <span dir="ltr" class=""><<a href="mailto:lkrzyzan@redhat.com" target="_blank" class="">lkrzyzan@redhat.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi there,<div class="">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 class=""><br class=""></div><div class="">In thread I do</div><div class="">KeycloakModelUtils.runJobInTransaction(sessionFactory, new KeycloakSessionTask() {<br class=""> @Override<br class=""> public void run(KeycloakSession session) {</div><div class="">…</div><div class="">EntityManager em = session.getProvider(JpaConnectionProvider.class).getEntityManager();<br class=""></div><div class="">TypedQuery<UserEntity> query = em.createQuery(<br class=""> "select u from UserEntity u where u.realmId = :realmId order by u.username", UserEntity.class);</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Unfortunately I got java.lang.NoClassDefFoundError: javax/persistence/EntityManager</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I tried to set various class loaders via</div><div class="">thread.setContextClassLoader(DefaultJpaConnectionProviderFactory.class.getClassLoader());</div><div class=""><br class=""></div><div class="">but with no success.</div><div class=""><br class=""></div><div class="">I’m running this on EAP 6.4.</div><div class=""><br class=""></div><div class="">What is the proper way how to retrieve entity manager for running custom queries?</div><div class=""><div class="">
<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;" class=""><br class="">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;" class=""><br class=""></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;" class="">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;" class=""><a href="http://jboss.org/" target="_blank" class="">jboss.org</a> Development Team</div>
</div>
<br class=""></div></div><br class="">_______________________________________________<br class="">
keycloak-user mailing list<br class="">
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank" class="">keycloak-user@lists.jboss.org</a><br class="">
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank" class="">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br class=""></blockquote></div><br class=""><div class=""><br class=""></div>
</div></div></div>
</div></blockquote></div><br class=""></div></body></html>