// Establish Spring Security context using the supplied username/password // The username and password needs to be set in the file SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken( Config.getProperty("user"),Config.getProperty("password") ) ); //Lookup ApiService Bean from the Client Application Context. try { applicationContext = new ClassPathXmlApplicationContext("classpath:client-applicationContext.xml"); api = applicationContext.getBean("apiService",ApiService.class); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }