[keycloak-user] Internal Server Error when trying to get (all) members of a group
Marek Posolda
mposolda at redhat.com
Wed Mar 23 09:47:32 EDT 2016
Feel free to create JIRA for this. Admin console is always using some
good default values for min and max, so it's not a very big issue IMO,
but still would be good to fix.
Marek
On 23/03/16 14:11, Guus der Kinderen wrote:
> Insta-update: passing explicit values to the method call works around
> the issue:
> public List<UserRepresentation> getAllUsersInGroup( String groupName )
> {
> RealmResource realmRes =keycloak.realm("myrealm" );
> GroupRepresentation group = realmRes.getGroupByPath("/" + groupName );
> GroupResource groupRes = realmRes.groups().group( group.getId() );
> return groupRes.members(0,Integer.MAX_VALUE);
> }
>
> On 23 March 2016 at 14:04, Guus der Kinderen
> <guus.der.kinderen at gmail.com <mailto:guus.der.kinderen at gmail.com>> wrote:
>
> Hiya,
>
> Using the admin-client on a Keycloak 1.9.1 instance, I'm running
> into something odd. I'm trying to obtain all members from a
> particular group in a particular realm. My code, simplified:
>
> public List<UserRepresentation> getAllUsersInGroup( String groupName )
> {
> RealmResource realmRes =keycloak.realm("myrealm" );
> GroupRepresentation group = realmRes.getGroupByPath("/" + groupName );
> GroupResource groupRes = realmRes.groups().group( group.getId() );
> return groupRes.members(null,null );
> }
>
> Oddly enough, the last line throws
> a javax.ws.rs.InternalServerErrorException.
>
> When I look at the log from my keycloak intance, I see a
> stacktrace that suggests that -2 is used for the maxResult value
> (but it isn't - it's null). What's going on here?
>
> 13:32:01,519 ERROR [io.undertow.request] (default task-40)
> UT005023: Exception handling request to
> /auth/admin/realms/myrealm/groups/ad2251c9-8e21-4eb6-903d-679f49cceb9e/members:
> org.jboss.resteasy.spi.UnhandledException:
> java.lang.IllegalArgumentException: Negative value (-2) passed to
> setMaxResults
> at
> org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
> at
> org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
> at
> org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:168)
> at
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:411)
> at
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
> at
> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
> at
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
> at
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
> at
> io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
> at
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
> at
> org.keycloak.services.filters.KeycloakSessionServletFilter.doFilter(KeycloakSessionServletFilter.java:78)
> at
> io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
> at
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
> at
> io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
> at
> io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
> at
> io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
> at
> org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
> at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> at
> io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
> at
> io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
> at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> at
> io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
> at
> io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
> at
> io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
> at
> io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
> at
> io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
> at
> io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
> at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> at
> org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
> at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
> at
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
> at
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
> at
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
> at
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
> at
> io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
> at
> io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.IllegalArgumentException: Negative value (-2)
> passed to setMaxResults
> at
> org.hibernate.jpa.spi.BaseQueryImpl.setMaxResults(BaseQueryImpl.java:131)
> at
> org.hibernate.jpa.spi.AbstractQueryImpl.setMaxResults(AbstractQueryImpl.java:78)
> at
> org.hibernate.jpa.spi.AbstractQueryImpl.setMaxResults(AbstractQueryImpl.java:32)
> at
> org.keycloak.models.jpa.JpaUserProvider.getGroupMembers(JpaUserProvider.java:382)
> at
> org.keycloak.models.cache.infinispan.DefaultCacheUserProvider.getGroupMembers(DefaultCacheUserProvider.java:203)
> at
> org.keycloak.models.UserFederationManager$2.query(UserFederationManager.java:194)
> at
> org.keycloak.models.UserFederationManager.query(UserFederationManager.java:297)
> at
> org.keycloak.models.UserFederationManager.getGroupMembers(UserFederationManager.java:190)
> at
> org.keycloak.services.resources.admin.GroupResource.getMembers(GroupResource.java:189)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
> at
> org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
> at
> org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:138)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)
> at
> org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:101)
> at
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
> ... 37 more
>
>
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160323/3c3ad299/attachment-0001.html
More information about the keycloak-user
mailing list