title: HIbernate struts2 session null pointer exception
body: <p>I am creating one simple login example using struts2 and hibernate. For doing this I am creating one session variable with @SessionTarget annotation. But when I am trying to use this session variable then I am getting null pointer exception. </p>
  
  <pre><code>            @SessionTarget
              Session session;
  
              public void userLogin(String userName, String password) {
                    try {
                    String hql = "select user_privilege from user_details log where log.userName=:userName and log.password=:passw";
                    Query query = session.createQuery(hql); // From here I am getting exception
                    query.setParameter("userName", userName);
                    query.setParameter("password", passw);
                    List result = query.list();
                    Iterator iterator = result.iterator();
                    while(iterator.hasNext()){
                      userId = (int) iterator.next();
                    }
                  } catch (HibernateException e) {
                  } finally {
                    //session.close();
                  }                   
              }
  </code></pre>