<div dir="ltr">Insta-update: passing explicit values to the method call works around the issue:<div><pre style="white-space:pre-wrap;color:rgb(0,0,0);font-family:&#39;DejaVu Sans Mono&#39;;font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold">public </span>List&lt;UserRepresentation&gt; getAllUsersInGroup( String groupName )<br>{<br>    RealmResource realmRes = <span style="color:rgb(102,14,122);font-weight:bold">keycloak</span>.realm( <span style="color:rgb(0,128,0);font-weight:bold">&quot;myrealm&quot; </span>);<br>    GroupRepresentation group = realmRes.getGroupByPath( <span style="color:rgb(0,128,0);font-weight:bold">&quot;/&quot; </span>+ groupName );<br>    GroupResource groupRes = realmRes.groups().group( group.getId() );<br>    <span style="color:rgb(0,0,128);font-weight:bold">return </span>groupRes.members( <span style="color:rgb(0,0,128);font-weight:bold">0</span>, <span style="font-size:9pt;background-color:rgb(228,228,255)">Integer</span><span style="font-size:9pt">.</span><span style="font-size:9pt;color:rgb(102,14,122);font-weight:bold;font-style:italic">MAX_VALUE</span><span style="font-size:9pt;color:rgb(0,0,128);font-weight:bold"> </span><span style="font-size:9pt">);</span><br>}</pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 23 March 2016 at 14:04, Guus der Kinderen <span dir="ltr">&lt;<a href="mailto:guus.der.kinderen@gmail.com" target="_blank">guus.der.kinderen@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hiya,</div><div><br></div><div>Using the admin-client on a Keycloak 1.9.1 instance, I&#39;m running into something odd. I&#39;m trying to obtain all members from a particular group in a particular realm. My code, simplified:</div><div><pre style="color:rgb(0,0,0);font-family:&#39;DejaVu Sans Mono&#39;;font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold">public </span>List&lt;UserRepresentation&gt; getAllUsersInGroup( String groupName )<br>{<br>    RealmResource realmRes = <span style="color:rgb(102,14,122);font-weight:bold">keycloak</span>.realm( <span style="color:rgb(0,128,0);font-weight:bold">&quot;myrealm&quot; </span>);<br>    GroupRepresentation group = realmRes.getGroupByPath( <span style="color:rgb(0,128,0);font-weight:bold">&quot;/&quot; </span>+ groupName );<br>    GroupResource groupRes = realmRes.groups().group( group.getId() );<br>    <span style="color:rgb(0,0,128);font-weight:bold">return </span>groupRes.members( <span style="color:rgb(0,0,128);font-weight:bold">null</span>, <span style="color:rgb(0,0,128);font-weight:bold">null </span>);<br>}<br></pre>Oddly enough, the last line throws a javax.ws.rs.InternalServerErrorException.</div><div><br></div><div>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&#39;t - it&#39;s null). What&#39;s going on here?</div><div><br></div><div><div><font face="monospace, monospace">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</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:168)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:411)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.keycloak.services.filters.KeycloakSessionServletFilter.doFilter(KeycloakSessionServletFilter.java:78)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at java.lang.Thread.run(Thread.java:745)</font></div><div><font face="monospace, monospace">Caused by: java.lang.IllegalArgumentException: Negative value (-2) passed to setMaxResults</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.hibernate.jpa.spi.BaseQueryImpl.setMaxResults(BaseQueryImpl.java:131)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.hibernate.jpa.spi.AbstractQueryImpl.setMaxResults(AbstractQueryImpl.java:78)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.hibernate.jpa.spi.AbstractQueryImpl.setMaxResults(AbstractQueryImpl.java:32)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.keycloak.models.jpa.JpaUserProvider.getGroupMembers(JpaUserProvider.java:382)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.keycloak.models.cache.infinispan.DefaultCacheUserProvider.getGroupMembers(DefaultCacheUserProvider.java:203)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.keycloak.models.UserFederationManager$2.query(UserFederationManager.java:194)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.keycloak.models.UserFederationManager.query(UserFederationManager.java:297)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.keycloak.models.UserFederationManager.getGroupMembers(UserFederationManager.java:190)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.keycloak.services.resources.admin.GroupResource.getMembers(GroupResource.java:189)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at java.lang.reflect.Method.invoke(Method.java:498)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:138)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:101)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>... 37 more</font></div></div><div><br></div></div>
</blockquote></div><br></div>