9 Replies Latest reply: Jul 2, 2009 6:14 AM by Mamatha RSS

    User name is null in user creation event

      Hi,

       

         I wrote a plug in which handles USER events but the problem is when i printed the user details on consul from the captured user event i get the USER NAME as NULL but the other values are there. only user name is getting as null

       

      why is this happening like this?

       

      Bala.

        • Re: User name is null in user creation event

          Bala,

           

           

          This sounds like a bug. Can you do me a favour and add a "new Exception().printStackTrace();" line to your event listener and post the top 15 or so lines from that stack trace? It'll help me isolate where the problem lies and correct it.

           

           

          Regards,

           

          Bruce Ritchie

          • Re: User name is null in user creation event
            Aaron Johnson

            hi Bala,

             

            Following up on what Bruce said, can you also post the details of your user configuration? Specifically, are you using LDAP, a custom authentication provider or the standard database authentication provider?

             

            Cheers,

             

            AJ

              • Re: User name is null in user creation event

                Hi Bruce and AJ,

                 

                        First thing is im not using LDAP or custom authentication. my objective is to capture User related events so i added a listener to capture those

                 

                here is the result after adding "new Exception().printStackTrace();"

                 

                 
                java.lang.Exception
                     at com.satmetrix.clearspace.plugin.example.widget.UserEventHandler.userCreated(UserEventHandler.java:28)
                     at com.jivesoftware.base.event.UserEventDispatcher.dispatchEvent(UserEventDispatcher.java:74)
                     at com.jivesoftware.base.profile.UserManagerImpl$UserEventHandler.fireUserCreatedEvent(UserManagerImpl.java:513)
                     at com.jivesoftware.base.profile.UserManagerImpl$UserEventHandler.receive(UserManagerImpl.java:541)
                     at com.jivesoftware.spi.ServiceEventDispatcher.dispatchEvent(ServiceEventDispatcher.java:50)
                     at com.jivesoftware.spi.user.impl.db.UserProviderImpl.create(UserProviderImpl.java:121)
                     at com.jivesoftware.base.profile.UserManagerImpl.createExternalUserIfNeeded(UserManagerImpl.java:179)
                     at com.jivesoftware.base.profile.UserManagerImpl.createUser(UserManagerImpl.java:109)
                     at com.jivesoftware.base.profile.UserManagerImpl.createUser(UserManagerImpl.java:94)
                     at com.jivesoftware.base.proxy.UserManagerProxy.createUser(UserManagerProxy.java:66)
                     at org.apache.jsp.admin.user_002dcreate_jsp._jspService(user_002dcreate_jsp.java:551)
                     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
                     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
                     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
                     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
                     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                     at com.jivesoftware.community.action.JiveAdminActionFilter.doFilter(JiveAdminActionFilter.java:36)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
                     

                 

                In the original post i said "when i debug" im using eclipse to build the plug ins and placed the breakpoints to debug. when i examine the USER object from captured user registration event all the values i given in the form are present except the user name value it gives the null value

                 

                but when i query the JIVEUSER table manually it has the user name stored in it not sure why its not present in the user object from user registration event

                 

                here is the custom listener code i used

                 

                public class UserEventHandler implements UserListener, Plugin {.....................
                .........................................
                public void userCreated(UserEvent event) {
                      Log.debug("User creation event is captured");
                      //Retriving user details from the event
                      User user = event.getUser();
                      new Exception().printStackTrace();   
                }
                

                 

                 

                Thank you,

                Bala.

                  • Re: User name is null in user creation event

                    Hi,

                        There is some additional information i noticed the name property of user object is persisting into database only after the user creation is completed

                     

                    Thank you,

                    Bala.

                    • Re: User name is null in user creation event

                      Bala,

                       

                      I just tried to reproduce this issue and was unable to:

                       

                      
                      UserEventDispatcher.getInstance().addListener(new UserListener() {
                      
                                  public void userCreated(UserEvent event) {
                                      User user = event.getUser();
                                      System.err.println(user);
                                      System.err.println("user.getUserName() " + user.getUsername());
                      
                                  }
                      
                                  public void userDeleted(UserEvent event) {
                                  }
                      
                                  public void userModified(UserEvent event) {
                      
                                  }
                      
                                  public void userLoggedIn(UserEvent event) {
                                  }
                              });
                      

                       

                      The output of that when I created a user included the username of the new user I just created.

                       

                       

                      Regards,

                       

                      Bruce Ritchie

                  • Re: User name is null in user creation event

                    thx for the support