Getting null pointer exception in java spring hibernate app
I have class Registration with username email password
I have following function in dao , service classes
 public Registration get( Integer id ) {
     logger.debug("Getting person");
        return registrationDAO.findUserByID(id);
     }
@Resource(name="registrationService")
    private RegistrationService registrationService;
    public Registration findUserByID(Integer ID) {
         try {
              Session session = sessionFactory.getCurrentSession();
              Registration person = (Registration) session.get(Registration.class,开发者_如何学C ID);
              return person;
         } catch (Exception e) {
                    System.out.println(e);
                    throw new RuntimeException("DAO failed", e);
                }
        }
I am using that function in following function
public UserDetails loadUserByUsername(String username)
            throws UsernameNotFoundException, DataAccessException {
        // Declare a null Spring User
        UserDetails user = null;
        logger.debug(username);
                //for testing -- i get error here
        Registration regUser = registrationService.get(1);
        logger.debug(regUser);
        try {
            DbUser dbUser = userDAO.searchDatabase(username);
I get error when i add this line
Registration regUser = registrationService.get(1);
            logger.debug(regUser);
Edit: For clarified question
@Resource
private RegistrationService registrationService;
See the tutorial at: http://download.oracle.com/javaee/5/tutorial/doc/bncjk.html#bncjl
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论