Announcement Announcement Module
No announcement yet.
context:annotation-config and UserService injection into webservice Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • context:annotation-config and UserService injection into webservice

    @javax.jws.WebService(endpointInterface = "... Here is my problem.

    In my "Entry Point" I am not getting UserService instantiated by "web container". If I use

    ugly way of loading (Commented out lines) it works fine. Can someone shed some lights on what

    I am doing wrong there.

    My service and impl

    public interface UserService {
    boolean authenticate(final String userName, final String password);

    public class UserServiceImpl implements UserService {
    private LdapTemplate ldapTemplate;

    public void setLdapTemplate(final LdapTemplate ldapTemplate) {
    this.ldapTemplate = ldapTemplate;
    public UserServiceImpl() {
    public boolean authenticate(String userName, String password) { .... }

    My entry point class for web service.

    @javax.jws.WebService(endpointInterface = "......AuthenticationPortType", targetNamespace = ".....", serviceName = "....", portName = "AuthenticationService", wsdlLocation = "...")
    public class AuthenticationBindingImpl {

    private static Logger log = Logger.getLogger(AuthenticationBindingImpl.class);

    private UserService userService;

    public void setUserService(UserService userService) {
    this.userService = userService;

    public AuthenticateResult authenticate(Authenticate parameters) {

    /** GenericApplicationContext appContext = new GenericApplicationContext();
    XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
    xmlReader.loadBeanDefinitions(new ClassPathResource(

    userService = (UserService) appContext.getBean("userService"); **/

    AuthenticateResult ar = new AuthenticateResult();
    long start = System.currentTimeMillis();"Authenticating : " + parameters.getUsername() + " : From : " + parameters.getSourceIp());

    //Following is NullPointer as userService is null (not instantiated
    boolean result = <b>userService.authenticate</b>(getUserName(parameters
    .getUsername()), parameters.getPassword());

    My config file

    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
    <constructor-arg ref="contextSource" />
    <bean id="userService" class="....UserServiceImpl">
    <property name="ldapTemplate" ref="ldapTemplate" />
    <bean id="authenticationService" class="....AuthenticationBindingImpl">
    <property name="userService" ref="userService" />