Sorry I do not understand very well. What class I need to bind with
RdbmsLogin? 

RdbmsLogin is an impl class that implements JAAS LoginModule. So there also
have other classes needed, including CallbackHandler, Principal, etc. 

Should I bind RdbmsLogin with LoginModule? I try to bind them together, e.g. 

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

but the log shows that accountDAO is null (as below). 

java.lang.NullPointerException
        at 
org.example.services.security.RdbmsLogin.validate(RdbmsLogin.java:133)

If I do not bind them together, the accountDAO is still null and throws
NullPointerException too.

Or what is the right way if I need to bind RdbmsLogin as well?

Many thanks.


Juan E. Maya wrote:
> 
> are u binding RdbmsLogin.java too?
> 
> On Mon, Aug 3, 2009 at 11:20 PM, Neo
> Anderson<[email protected]> wrote:
>>
>> Yes I do see the log (catalina.out) shows
>>
>>                                 IAccount: DEFINED
>>                              IAuthService: DEFINED
>>
>> And what makes me confused is that the log also shows that the IAccount
>> is created when invoking AuthService.java
>>
>> [DEBUG] AppModule.IAccount Creating service 'IAccount'.
>> [AuthService.java] accountDAO is null?<Proxy for
>> Account(org.example.domain.IAccount)> //printed by System.out.println
>>
>> But when it comes to execute RdbmsLogin.java, the '@private IAccount
>> accountDAO' in RdbmsLogin becomes null because I use System.out.println()
>> to print the object accountDAO (accountDAO.findUserByAccount(new
>> User("-1", account, "", password));) and the result is as follow:
>>
>> [RdbmsLogin.java] accountDAO is null? null
>>
>> The flow of execution is
>>
>> Login.java -> IAuthService.java/ AuthService.java -> RdbmsLogin.java
>>
>> in AuthService and Rdbmslogin both contain '@Inject private IAccount
>> accountDAO' annotation; but the accountDAO in AuthService is not null and
>> I can execute the function e.g. findUserByAccount without a problem.
>> Unfortunately, when it execute accountDAO in RdbmsLogin, then the
>> accountDAO is null. (This is just for comparison so I put two Inject
>> annotation in AuthService and RdbmsLogin classes)
>>
>> Also, if I remove IAuthService/ AuthService, directly calling
>> RdbmsLogin.java from Login.java shows the accountDAO ('@Inject private
>> IAccount accountDAO') in RdbmsLogin.java is still null.  (This execution
>> flow should be Login.java -> RdbmsLogin.java )
>>
>> The AppModule.java contains the binding clauses
>>
>> public class AppModule {
>>        public static void bind(ServiceBinder binder) {
>>                binder.bind(IAuthService.class, AuthService.class);
>>                binder.bind(IAccount.class, Account.class);
>>        }
>> ...
>> }
>>
>> I think I may do something wrong, but I completely am not aware of it. Is
>> there anything I miss or misconfigure?
>>
>> Thanks in advice.
>>
>> --- On Mon, 3/8/09, Juan E. Maya <[email protected]> wrote:
>>
>>> From: Juan E. Maya <[email protected]>
>>> Subject: Re: Tapestry 5 IoC binding interface with impl problem
>>> To: "Tapestry users" <[email protected]>
>>> Date: Monday, 3 August, 2009, 7:44 PM
>>> Do u see the DAO being created when
>>> the application goes up? Tapestry
>>> does a very good job informing all the services that are
>>> configured.
>>> If it's not in the log then u r not binding the service.
>>>
>>> There r 2 ways to bind services in a module:
>>> public static void bind(ServiceBinder binder) {
>>>    binder.bind(Interface.class,
>>> Impl.class);
>>> }
>>>
>>> or
>>>  public static Interface buildServiceName()
>>>   {
>>>      return new InteraceImpl();
>>>   }
>>>
>>>
>>> I really didn't get what u were trying to do in the first
>>> email.
>>> ApplicationStateCreator<IAccount> account =
>>>
>>>        new
>>> ApplicationStateCreator<IAccount>(){
>>>
>>>
>>>    public IAccount create() {
>>>
>>>
>>>        return new AccountDAO();
>>>
>>>
>>>    }
>>>
>>>        };
>>>
>>>
>>>    configuration.add(IAccount.class, new
>>> ApplicationStateContribution("session", account));
>>>
>>>
>>> in what method of ur App module is that code?
>>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
> 
> ---------------------------------------------------------------------
> 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-tp24793396p24799569.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