[crowd] Crowd 2.3 Customs Directory example code
Asked by Jerome Taylor:

Does anyone have example code of a custom directory for Crowd 2.3. I am trying to create one and am getting a java.lang.NullPointerException. Exception trace stack:

java.lang.NullPointerException  
at com.atlassian.crowd.manager.application.ApplicationServiceGeneric.isUserAuthorised(ApplicationServiceGeneric.java:171)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  
at java.lang.reflect.Method.invoke(Method.java:597)  
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)  
at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:20)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)  
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)  
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)  
at $Proxy10.isUserAuthorised(Unknown Source)  
at com.atlassian.crowd.manager.application.CachingApplicationService.isUserAuthorised(CachingApplicationService.java:72)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  
at java.lang.reflect.Method.invoke(Method.java:597)  
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)  
at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:20)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)  
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)  
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)  
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)  
at $Proxy10.isUserAuthorised(Unknown Source)

public class CSPDirectoryServer implements RemoteDirectory {

...

**public** User authenticate(String name, PasswordCredential credential)

**throws** UserNotFoundException, InactiveAccountException,

InvalidAuthenticationException, ExpiredCredentialException,

OperationFailedException {

*log* .info("authenticate(" + name + ")");

UserTemplate user = **new** UserTemplate(name, getDirectoryId());

user.setName(name);

user.setFirstName("Joe");

user.setLastName("Nevermind");

user.setDisplayName("Nevermind, Joe (" + name + ")");

user.setEmailAddress(name + "@cmp.com");

user.setActive(**true** );

*log* .info("User: " + user.toString());

**return** (User) user;

}

....

}


Answers:
author: Jeff Kirby
body: I recommend downloading the source code for Crowd 2.3 from [my.atlassian.com](http://my.atlassian.com).

Then in your IDE of choice, set a break point at line 171 of com.atlassian.crowd.manager.application.ApplicationServiceGeneric line 171

and see what it is that is null  


Tags: user-directory