2 Replies Latest reply on Jan 22, 2008 1:05 AM by meaobao

    Null Pointer Exception when getting the permissions manager !!


      Hello everybody,



      I have a strange problem when i try to get the permissions manager of a just created community !! it always return null !! here is my code snippet,



      AuthToken systemAuthToken=AuthFactory.getSystemAuthToken();



      Community rootCommunity = JiveApplication.getContext(systemAuthToken).getCommunityManager().getRootCommunity();



      Community userDashboard = rootCommunity.createCommunity(communityID,communityID, communityDescription);



      PermissionsManager permissionsManager = userDashboard.getPermissionsManager() ;



      Taking in consideration that all parameters are not NULL;



      thanks in advance.






        • Re: Null Pointer Exception when getting the permissions manager !!

          This is probably one of the most confusing things and without looking at the source I would've had no clue what is going on here, as I have run into this issue before, here is the code from DbCommunity - the implementation of the interface you are accessing:


              public PermissionsManager getPermissionsManager() {
                  // handled at the proxy layer
                  return null;


          As you can see, from a poorly designed API comes a poorly defined implementation. So, if you are using the System Auth Token to create communities don't expect to be able to retrieve the permissions manager from the community. The simple workaround is this, create a convenience method in your class:


              private PermissionsManager getPermissionsManager(Community community) {
                  return new PermissionsManagerProxy(JiveConstants.COMMUNITY, community.getID(),
                          new AdminAuthToken(), new Permissions(Permissions.SYSTEM_ADMIN));


          In the mean time I will make certain this situation is rectified moving forward.