The NullPointerException is being thrown because you are directly instantiating PersonDaoHibernate rather than allowing Spring to inject it as a dependency. The session factory will not have been set on the DAO, so the exception will be thrown. Could I suggest you have a look at the relevant tutorial for your web framework? I believe it will help you get things up and running.
For AppFuse 1.9.4 the tutorials are here: http://raibledesigns.com/wiki/Wiki.jsp?page=CreateDAO For AppFuse 2.0.x the tutorials are here: http://www.appfuse.org/display/APF/Tutorials Mike. On 8/10/07, Tony.Cesc <[EMAIL PROTECTED]> wrote: > > > Thanks for your response but I did have setter and getter in LoginAction > clas > (still got null exception)s. > Here is my LoginAction class: > > public class LoginAction extends BaseAction { > > private Person person; > PersonDao personDao; > > public Person getPerson() { > return person; > } > > public void setPerson(Person person) { > this.person = person; > } > > > public PersonDao getPersonDao() { > return personDao; > } > > public void setPersonDao(PersonDao personDao) { > this.personDao = personDao; > } > > public String login() { > System.out.println(person.getUsername()); > System.out.println(person.getPassword()); > PersonDaoHibernate pdh = new PersonDaoHibernate(); > boolean valid = pdh.authentication(person.getUsername(), > person.getPassword()); > System.out.println(valid); > > return SUCCESS; > } > } > > And which is "the relevant entries to the Spring configuration files" ? > > Thanks again. > > > Michael Horwitz wrote: > > > > You will need to wire up your action using Spring. Add a getter and > setter > > method for PersonDao (abd make pdh an attribute of the action class), > add > > the relevant entries to the Spring configuration files and all should > work > > fine. > > > > Mike. > > > > On 8/10/07, Tony.Cesc <[EMAIL PROTECTED]> wrote: > >> > >> > >> Hi, > >> I am newbie. I am trying to write new login function which is not used > >> acegi. > >> - Wrote LoginAction class > >> public String login() { > >> System.out.println(person.getUsername()); > >> System.out.println(person.getPassword()); > >> PersonDaoHibernate pdh = new PersonDaoHibernate(); > >> boolean valid = pdh.authentication(person.getUsername(), > >> person.getPassword()); > >> System.out.println(valid); > >> > >> return SUCCESS; > >> } > >> > >> - In LoginAction, I have login fuction which is call authentication > >> function > >> in PersonDaoHibernate Class > >> public boolean authentication(String username, String password) { > >> System.out.println(username); > >> System.out.println(password); > >> try { > >> List lists = getHibernateTemplate().find( > >> "from Person where username=?", username); > >> if (lists.isEmpty()) { > >> return false; > >> } else { > >> return true; > >> } > >> } catch (Exception ex) { > >> System.out.println(ex.toString()); > >> > >> return false; > >> } > >> } > >> > >> The result is > >> user1 > >> 123 > >> java.lang.NullPointerException > >> > >> Thanks for any suggestion. > >> > >> Regard, > >> Tony > >> -- > >> View this message in context: > >> > http://www.nabble.com/NullPointerException-when-try-to-retrieve-data-tf4248239s2369.html#a12089884 > >> Sent from the AppFuse - User mailing list archive at Nabble.com. > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/NullPointerException-when-try-to-retrieve-data-tf4248239s2369.html#a12090345 > Sent from the AppFuse - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
