Thanks for reply. 

I am a bit confused now. Would you please give a bit more explain on how to 
add make AccountDAO a service?

Why I am confused is because I discover when I switch back using the old
testing code, it works correctly. The way how I obtain the AccountDAO is 

in Login.java 

        @Inject
        private IAuthService auth;

        Object onSubmitFromLogin(){
               ...  
                user = auth.authenticate(new User("-1", this.account, "", 
this.password));
                ...
        }

in AppModule.java

        public static void bind(ServiceBinder binder) {
                binder.bind(IAuthService.class, AuthService.class);
                binder.bind(IAccount.class, Account.class);
        }

in AuthService.java 

        @Inject 
        private IAccount accountDAO;

        public User authenticate(User user){
                ...
                User u = accountDAO.findUserByAccount(account);
                ...
        }

Then when accessing the login page from web, everything works fine (the
accountDAO is not null).

But when switching using one that integrates JAAS then the accountDAO
becomes null. For instance, in AuthService.java the code switch to use
RdbmsLogin.java where injecting accountDAO (@Inject private IAccountDAO) 

in AutheService.java 

public User authenticate(User user){
...
                RdbmsCallbackHandler handler = 
                        new RdbmsCallbackHandler(account, password);
                try{
                        LoginContext context = 
                                new LoginContext(JAAS_REALM, handler);
                        context.login();
                }catch(LoginException le){
                        le.printStackTrace();
                }
...
}

in RdbmsLogin.java

public class RdbmsLogin implements LoginModule{
        public boolean login() throws LoginException {  
                ... 
                flag = validate(account, password);
                ...
        }
        private boolean validate(String account, String password){
                ...
                // the accountDAO is always null here, but the accountDAO 
injected inside
the AuthService is not null. 
                User user = accountDAO.findUserByAccount(new User("-1", 
account, "",
password));
                ...
        }

Or if I simply replace AuthService with RdbmsLogin, the AccountDAO injected
inside RdbmsLogin is still null. 

What additional setting I need to configure?

Thanks for patiently answering my questions. 

I appreciate it.


Thiago H. de Paula Figueiredo wrote:
> 
> Em Mon, 03 Aug 2009 13:03:51 -0300, Neo Anderson  
> <[email protected]> escreveu:
> 
>> The problem is that it looks like accountDAO is always null. It seems to  
>> me that the IAccount does not successfully bind with AccountDAO class;
> 
> It wasn't, unless you add make AccountDAO a service. Just instantiating it  
> and using as part of the configuration of another service doesn't make it  
> a service.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Tapestry-5-IoC-binding-interface-with-impl-problem-tp24793396p24796853.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to