I am currently creating web application using Struts2 with Struts2-spring plugin.
here is a snippet of my applicationContext.xml
<bean id="sessionFactory" scope="singleton"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
<!-- Springs Hibernate Transaction Manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven />
<!-- Create DAO Objects -->
<bean id = "userDao" class = "org.hitplay.users.dao.UserDao" scope = "singleton">
<property name ="sessionFactory" ref = "sessionFactory" />
</bean>
<bean id = "adminDao" class = "org.hitplay.admin.dao.AdminDao" scope = "singleton">
<property name ="sessionFactory" ref = "sessionFactory" />
</bean>
<bean id="authenticateLoginService" class="org.hitplay.services.AuthenticateLoginService" scope="singleton">
<property name="userDao" ref="userDao" />
<property name="adminDao" ref="adminDao" />
</bean>
<bean id="accountAuthenticationManager" class="org.hitplay.authentication.manager.AccountAuthenticationManager" scope="singleton">
<property name="authenticateLoginService" ref="authenticateLoginService" />
</bean>
Here is my AccountAuthenticationManager class
@Transactional
public class AccountAuthenticationManager implements AuthenticationManager {
protected static Logger logger = Logger.getLogger("service");
// Our custom DAO layer
private AuthenticateLoginService authenticateLoginService;
public AuthenticateLoginService getAuthenticateLoginService() {
return authenticateLoginService;
}
public void setAuthenticateLoginService(
AuthenticateLoginService authenticateLoginService) {
this.authenticateLoginService = authenticateLoginService;
}
public Authentication authenticate(Authentication auth) throws AuthenticationException {
System.out.println(authenticateLoginService);
//Some more codes here
}
As You can see on our mapping we are injecting the authenticateLoginService
inside the AccountAuthenticationManager
class. we've even provided setters and getters for authenticateLoginService
but as you can see when we run the
authenticate(Authentication auth)
method the authenticationLoginService
is returning null we have no idea why this is happening. please note that AccountAuthenticationManager is not a Struts Action
we are currently using struts2-spring plugin and spring security.