Announcement Announcement Module
Collapse
No announcement yet.
Trouble with PagedResultsRequestControl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with PagedResultsRequestControl

    Currently I have:

    Code:
            PagedResultsRequestControl requestControl;
            requestControl = new PagedResultsRequestControl(3);
    
            CollectingNameClassPairCallbackHandler handler = ldapTemplate.new AttributesMapperCallbackHandler(groupAttributesMapper);
    
            ldapTemplate.search(baseDN, filter.encode(), searchControls, handler, requestControl);
            PagedResultsCookie cookie = requestControl.getCookie();
    
            List handlerList = handler.getList();
    
            // page the results
            return ldapPropertiesMapper.pageResults(searchContext, handlerList);
    However I am getting this exception:

    Code:
    java.lang.NullPointerException
    	at org.springframework.ldap.support.control.AbstractRequestControlDirContextProcessor.preProcess(AbstractRequestControlDirContextProcessor.java:72)
    	at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:267)
    	at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:231)
    Looking into the code it appears the src is performing:

    Code:
    Control[] requestControls = ldapContext.getRequestControls();
    The problem here is that I have not set any request controls. In my pre-springldap code I had:

    Code:
    if (isPagingResultsControl()) {
           Control[] ctls = new Control[]{new PagedResultsControl(pageSize)};
           connection.setRequestControls(ctls);
    }
    What I am wondering is how could I set the controls on the ldapTemplate or am I going about all this wrong?

  • #2
    Ouch, that looks like a bug. It's clearly stated in the javadocs that the array may be null. Odd that we didn't encounter this in our integration tests; I guess it might be server dependant. Please file a bug report on our Jira.

    Comment


    • #3
      Any chance we could get a point release to fix this?

      http://opensource.atlassian.com/proj...browse/LDAP-37

      Comment


      • #4
        Originally posted by jstepka View Post
        Any chance we could get a point release to fix this?

        http://opensource.atlassian.com/proj...browse/LDAP-37
        I would say the chances for that is rather slim, it's just too much work with doing a release for it to be practical to do point releases for isolated bugs. We will of course fix the issue in the 1.2 release, but that is still at least a month away. Sorry.

        If this is absolutely crucial for you guys I'd recommend downloading the buildable distribution, making the change there and building the stuff yourself while waiting for the next release. It's not pretty but that's probably the way it needs to be.

        Comment


        • #5
          Configuring the Buildable archive

          Is there document that scripts how to setup the build environment for this project?

          Comment


          • #6
            Actually, we haven't any build instructions (although it is something we're aiming to include for version 1.2 - which of course won't help you).

            Either way, you'll need ant 1.6+ and java 1.4.2+, which the respective environment variables (ANT_HOME, JAVA_HOME) set appropriately. You'll also need javacc version 4.0, which is used in the distinguished name parsing code.

            You'll also want to do some configuration:
            in spring-ldap/spring-ldap/project.properties, specify your javacc installation directory (or you can of course send it as a system property when running ant. You'll probably also want to up the version number (project.base.version) in the same file (or give this version some particular identification) in order to avoid ivy problems.

            When this is done you should be all set to build: just run 'ant dist' in spring-ldap/spring-ldap and you should get a jar file under spring-ldap/integration-repo (and in your ivy cache).

            Hope this works for you.

            Comment


            • #7
              I figured as much . I ended up just editing the file I knew was an issue by hand and created my own distribution. The paging works great though the documentation might be improved a bit, I would suggest an example wit something like this:

              Code:
              PagedResultsRequestControl requestControl;
                      requestControl = new PagedResultsRequestControl(DEFAULT_PAGE_SIZE);
              
                      CollectingNameClassPairCallbackHandler handler = ldapTemplate.new AttributesMapperCallbackHandler(groupAttributesMapper);
              
                      byte[] cookie;
              
                      do
                      {
                          ldapTemplate.search(baseDN, filter.encode(), searchControls, handler, requestControl);
              
                          requestControl = new PagedResultsRequestControl(3, requestControl.getCookie());
              
                          cookie = requestControl.getCookie().getCookie();
                      }
                      while ((cookie != null) && (cookie.length != 0));
              I have tested this code verses AD 2003, SunONE and a Zimbra OpenLDAP install and everything seemed to work out well enough.

              Another comment if you are up to hearing them is, the 'ldapTemplate.new AttributesMapperCallbackHandler' syntax was a bit confusing because I have not seen anything like that before.

              I certainly understand it but looking at it took a minute to grapple.

              Thanks for this new feature, it's great!

              Comment


              • #8
                Rather than changing project.properties, I ususally prefer adding a local build.properties with my own configuration stuff, like where I put my JavaCC installation.

                Comment


                • #9
                  Originally posted by jstepka View Post
                  I figured as much . I ended up just editing the file I knew was an issue by hand and created my own distribution. The paging works great though the documentation might be improved a bit, I would suggest an example wit something like this:
                  Thanks for the suggestion, the documentation could certainly be improved here.

                  Originally posted by jstepka View Post
                  Another comment if you are up to hearing them is, the 'ldapTemplate.new AttributesMapperCallbackHandler' syntax was a bit confusing because I have not seen anything like that before.
                  The syntax is ugly, but the standard way of creating an instance of a nested, non-static class. This will be solved automatically for the 1.2 release, as these classes will be promoted to top-level ones.

                  Originally posted by jstepka View Post
                  Thanks for this new feature, it's great!

                  Comment


                  • #10
                    PagedResults

                    Hello,
                    I tried using the PagedResultsRequestControl , I wanted to know the total results.

                    But the method getResultSize returns a value "0". I was expecting it to be equal to the number of entities that matched the search criteria.


                    Another question was if I specify that I want "x" entries and this value is greater than the total entites which match the filter what would happen?

                    I haven't yet obtained the cookie and paged through the data , I was hoping to get the total results value and then page.

                    Comment


                    • #11
                      From the RFC2696:

                      If the page size is greater than or equal to the sizeLimit value, the server should ignore the control as the request can be satisfied in a single page.
                      In the control returned to the client, the size MAY be set to the server's estimate of the total number of entries in the entire result set. Servers that cannot provide such an estimate MAY set this size to zero (0).

                      Comment


                      • #12
                        Referrals and Paging

                        I am trying to use the PagedResultsRequestControl against the AD server and I am implementing my own paging by obtaining small pages of data.

                        I ran into a problem where I needed the referrals to be followed. So I figured if I supplied the property java.naming.referrals = follow in the baseEnvironmentProperties then it should work.

                        Well I read some more on the spring framework where they state they cannot maually follow referrals which is fine then this property should have no effect.

                        Instead I get this exception

                        java.lang.NullPointerException
                        at org.springframework.ldap.support.control.AbstractR equestControlDirContextProcessor.preProcess(Abstra ctRequestControlDirContextProcessor.java:72)
                        at org.springframework.ldap.LdapTemplate.search(LdapT emplate.java:267)



                        Now the strange part is when I have the ignorePartialResultsException set to true I don't get any exceptions well I also don't get all my data.

                        Please help !!.. Is there any way to set to follow referrals without breaking paging or is there something I am missing.

                        Comment


                        • #13
                          ManageReferralControl

                          I was debugging the AbstractRequestControlDirContextProcessor, when I don't set the java.naming.referral property to follow, there is a control ManageReferralControl being added to the array of request controls.

                          But once set the referral property , that control does not get added and I get the null pointer exception.

                          My question is how is this control getting added, its looks like the purpose is to manager referrals and next question is how do I manually handle referrals.

                          Comment


                          • #14
                            The problem with the null pointer in AbstractRequestControlDirContextProcessor is a known bug, fixed in release 1.2-RC1 which is due any week now.

                            With regards to manually following referrals, this is actually also a requested feature. At the moment this is not scheduled with the 1.2 release program, but if you feel that it is an important feature you should vote for it, which would improve the chances that it will be fixed sooner.

                            Comment


                            • #15
                              Question

                              I faced a problem with the ACEGI framework where I was getting a partial results exception.

                              I supplied the java.naming.referral = follows and it did get resolved. I know that spring ldap uses a different context implementation ,isn't there a way to do it how ACEGI does?

                              Comment

                              Working...
                              X