java.lang.IllegalArgumentException: No query defined for that name

2,729 views
Skip to first unread message

Sagun Tumkar

unread,
May 8, 2022, 3:49:24 AM5/8/22
to Keycloak Dev
Hi There,

I implemented custom JPA provider in my project and everything was working fine till now. But now I am trying to migrate to Keycloak 18 (Quarkus) from keycloak 15 and started getting below error for the same JPA provider.

java.lang.IllegalArgumentException: No query defined for that name [findByTenantId]
    at org.hibernate.internal.AbstractSharedSessionContract.buildQueryFromName(AbstractSharedSessionContract.java:923)
    at org.hibernate.internal.AbstractSharedSessionContract.createNamedQuery(AbstractSharedSessionContract.java:1038)
    at org.hibernate.internal.AbstractSessionImpl.createNamedQuery(AbstractSessionImpl.java:23)
    at jdk.internal.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.keycloak.connections.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:60)


I referred the "domain-extension" example from the "examples" directory of the keycloak source code and I don't see anything different from the current setup I have. Is there something changed with the way we add custom JPA providers? I would really appreciate your help.

I didn't ask this question on discourse group as looks like someone already asked this question and didn't get any answer (https://keycloak.discourse.group/t/keycloak-17-0-1-throws-exception-for-no-query-defined-for-that-name-for-named-query-in-custom-jpa/15103)

Thanks,
Sagun

Sagun Tumkar

unread,
May 8, 2022, 6:06:29 AM5/8/22
to Keycloak Dev
Seems like the provider itself is not loaded. When I am trying to find the entity by it's ID I am getting below error

java.lang.IllegalArgumentException: Unable to locate persister: <My Entity Path>

Sagun Tumkar

unread,
May 8, 2022, 7:26:14 PM5/8/22
to Keycloak Dev
Is there any documentation available on how to add custom JPA provider in Keycloak Quarkus? I tried every possible thing but nothing works. This use to work in wildfly and I didn't see any reference in server documentation where it says JPA custom providers would not work with Keycloak Quarkus. Can someone please help with this?

Sagun Tumkar

unread,
May 10, 2022, 12:47:51 AM5/10/22
to Keycloak Dev
Wanted to check again if anyone facing this issue. This is the very basic use case where we are want to register custom JPA entity. I even tried adding persistence.xml file but it didn't work either.

Dominik Guhr

unread,
May 10, 2022, 1:42:46 AM5/10/22
to Sagun Tumkar, Keycloak Dev
Hi Sagun,

there's a new quarkus related example here[1] in the quickstarts repository. Could you please see if you get it working following that code/readme? Thanks!

Best regards,
Dominik


--
You received this message because you are subscribed to the Google Groups "Keycloak Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-dev/fc4bbacf-6992-41f5-b11c-d687cb4a228dn%40googlegroups.com.

Sagun Tumkar

unread,
May 10, 2022, 4:29:07 AM5/10/22
to Keycloak Dev
Thanks for the pointer Dominik. This is really helpful as the first step. But in this example we are trying to connect to custom user store. In my case the datasource should be same as keycloak's. Do I still need to create quarkus.properties file in conf folder, and if yes what should be the content in this scenario?
Reply all
Reply to author
Forward
0 new messages