title: Hibernate and Struts2 java.lang.NullPointerException w/CRUD Demo
body: <p>I have a project which I am using Hibernate and Struts2 together, and I am new to both of them.</p>
  
  <p>I am having trouble working out the CRUD process with the Hibernate and Struts2 combinations. I want to do this in a specific way, but am having trouble. To replicate the issue I am having outside of my main project I downloaded the WAR from this tutorial and successfully got it running:
  <a href="http://struts.apache.org/2.x/docs/crud-demo-i.html" rel="nofollow noreferrer">http://struts.apache.org/2.x/docs/crud-demo-i.html</a></p>
  
  <p>Then I introduced Hibernate to it by making the following changes:</p>
  
  <p>1) First I added the JARs from my real project to this one to make sure I was running all the same versions of everything. The key points are I am suing Hibernate 3, Struts2, and the FullHibernateCore plugin to link them. For more detail, here are the JARs I am using:</p>
  
  <pre><code>antlr-2.7.7.jar
  commons-collections-3.2.1.jar
  commons-fileupload-1.2.2.jar
  commons-io-2.0.1.jar
  commons-lang-2.5.jar
  commons-logging-1.1.1.jar
  commons-logging-api-1.1.jar
  dom4j-1.6.1.jar
  freemarker-2.3.18.jar
  hibernate3.jar
  hibernate-jpa-2.0-api-1.0.1.Final.jar
  hibernate-testing.jar
  hibernate-validator.jar
  javassist-3.15.0-GA.jar
  jboss-logging-3.1.0.CR2.jar
  jboss-transaction-api_1.1_spec-1.0.0.Final.jar
  jta-1.1.jar
  log4j-1.2.15.jar
  mysql-connector-java-5.1.18-bin.jar
  ognl-3.0.4.jar
  slf4j-api-1.6.1.jar
  slf4j-log4j12-1.6.1.jar
  struts2-core-2.3.1.2.jar
  struts2-fullhibernatecore-plugin-2.2.2-GA.jar
  xwork-core-2.3.1.2.jar
  </code></pre>
  
  <p>2) Added hibernate.cfg.xml as follows:</p>
  
  <p>
  </p>
  
  <p></p>
  
  <pre><code>&lt;!-- a SessionFactory instance listed as /jndi/name --&gt;
  &lt;session-factory&gt;
  
      &lt;!-- DB Connection Settings --&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306&lt;/property&gt;
      &lt;property name="connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"&gt;&lt;/property&gt;
      &lt;property name="hibernate.default_schema"&gt;test2&lt;/property&gt;
      &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt; 
  
      &lt;!-- DB Dialect --&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
      &lt;!-- Echo SQL --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Model Mappings --&gt;
      &lt;mapping class="com.aurifa.struts2.tutorial.model.Employee"/&gt; 
      &lt;mapping class="com.aurifa.struts2.tutorial.model.Department"/&gt; 
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>3) Updated com.aurifa.struts2.tutorial.model.Department &amp; com.aurifa.struts2.tutorial.model.Employee with persistence annotation.</p>
  
  <p>4) Created com.rwblackburn.struts2.tutorial.dao.InitHibernate, and executed it to create initial DB and populate it with the same data as demo:</p>
  
  <pre><code>package com.rwblackburn.struts2.tutorial.dao;
  
  import java.util.Date;
  import java.util.GregorianCalendar;
  import java.util.List;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.AnnotationConfiguration;
  import org.hibernate.tool.hbm2ddl.SchemaExport;
  
  import com.aurifa.struts2.tutorial.model.Department;
  import com.aurifa.struts2.tutorial.model.Employee;
  
  public class InitHibernate {
  
  /**
   * @param args
   */
  public static void main(String[] args) {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass( Employee.class );
      config.addAnnotatedClass( Department.class );
      config.configure("hibernate.cfg.xml");
  
      // Create annotated class tables
      new SchemaExport(config).create(true, true);
  
      // Need to be careful with this, move it to a Struts global plugin?
      SessionFactory factory = config.buildSessionFactory();
      Session session = factory.openSession();
      session.beginTransaction();
  
      session.beginTransaction();
  
      // Create Departments
      Department dptAccounting = new Department( new Integer(100), "Accounting");
      Department dptRandD = new Department( new Integer(200), "R &amp; D");
      Department dptSales = new Department( new Integer(300), "Sales" );
      session.save(dptAccounting);
      session.save(dptRandD);
      session.save(dptSales);
  
      // Create Employees
      session.save(new Employee(new Integer(1), "John", "Doe", new Integer(36), dptAccounting));
      session.save(new Employee(new Integer(2), "Bob", "Smith", new Integer(25), dptSales));
  
      session.getTransaction().commit();
  
  }
  
  }
  </code></pre>
  
  <p>5) Created com.rwblackburn.struts2.tutorial.dao.EmployeeHibernateDao which implements EmployeeDao</p>
  
  <pre><code>package com.rwblackburn.struts2.tutorial.dao;
  
  import java.util.List;
  
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  
  import com.aurifa.struts2.tutorial.dao.EmployeeDao;
  import com.aurifa.struts2.tutorial.model.Employee;
  import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
  import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;
  
  public class EmployeeHibernateDao implements EmployeeDao {
  @SessionTarget
  protected Session session;
  
  @TransactionTarget
  protected Transaction transaction;
  
  @SuppressWarnings("rawtypes")
  @Override
  public List getAllEmployees() {
      return session.createQuery( "from Employee" ).list();
  }
  
  @Override
  public Employee getEmployee(Integer id) {
      Employee emp = new Employee();
      session.load(emp, id );
      return emp;
  }
  
  @Override
  public void update(Employee emp) {
      session.update(emp);
  
  }
  
  @Override
  public void insert(Employee emp) {
      session.save(emp);
  }
  
  @Override
  public void delete(Integer id) {
      Employee emp = new Employee();
      session.load(emp, id );
      session.delete(emp);
  }
  
  }
  </code></pre>
  
  <p>6) Created com.rwblackburn.struts2.tutorial.dao.DepartmentHibernateDao which implements DepartmentDao</p>
  
  <pre><code>package com.rwblackburn.struts2.tutorial.dao;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  
  import com.aurifa.struts2.tutorial.dao.DepartmentDao;
  import com.aurifa.struts2.tutorial.model.Department;
  import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
  import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;
  
  public class DepartmentHibernateDao implements DepartmentDao {
  @SessionTarget
  protected Session session;
  
  @TransactionTarget
  protected Transaction transaction;
  
  @SuppressWarnings("rawtypes")
  @Override
  public List getAllDepartments() {
      return session.createQuery( "from Department" ).list();
  }
  
  @SuppressWarnings("rawtypes")
  @Override
  public Map getDepartmentsMap() {
      Map&lt;Integer, Department&gt; departmentsMap = new HashMap&lt;Integer, Department&gt;();
      Iterator iter = this.getAllDepartments().iterator();
      while( iter.hasNext() ) {
          Department dept = (Department)iter.next();
          departmentsMap.put(dept.getDepartmentId(), dept );
      }
      return departmentsMap;
  }
  
  }
  </code></pre>
  
  <p>7) Updated EmployeeDaoService &amp; DepartmentDaoService to use the new hibernate DAOs instead of the "NoDB" version from the demo</p>
  
  <p>Now, InitHibernate runs just fine, so I know at least that much works and the DB itself is fine. However, when I try to load up the project in a browser the index.action page gives this error:</p>
  
  <pre><code>java.lang.NullPointerException
     com.rwblackburn.struts2.tutorial.dao.DepartmentHibernateDao.getAllDepartments(DepartmentHibernateDao.java:26)
      com.aurifa.struts2.tutorial.service.DepartmentDaoService.getAllDepartments(DepartmentDaoService.java:16)
  com.aurifa.struts2.tutorial.action.EmployeeAction.prepare(EmployeeAction.java:35)
  com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:167)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
  org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
  com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
  com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
  org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
  org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)
  org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
  org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
  org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
  org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
  java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>When I do a debug trace I can confirm that the Session and Transaction variables in DepartmentHibernateDao are in fact null. </p>
  
  <p>After doing a lot of searching around I found this thread:
  <a href="https://stackoverflow.com/questions/6294764/struts2-full-hibernate-plugin-session-is-closed">Struts2 + Full Hibernate Plugin --&gt; Session is Closed?</a></p>
  
  <p>This seems to be the same issue I was having. However, even if I downgrade by Struts version to 2.1.6, I still have the problem, Here is my new libraries:</p>
  
  <pre><code> antlr-2.7.2.jar
   commons-collections-3.2.jar
   commons-fileupload-1.2.1.jar
   commons-io-1.3.2.jar
   commons-lang-2.3.jar
   commons-logging-1.0.4.jar
   commons-logging-api-1.1.jar
   commons-validator-1.3.1.jar
   dom4j-1.6.1.jar
   freemarker-2.3.13.jar
   hibernate3.jar
   hibernate-jpa-2.0-api-1.0.1.Final.jar
   hibernate-testing.jar
   hibernate-validator.jar
   javassist-3.15.0-GA.jar
   jboss-logging-3.1.0.CR2.jar
   jboss-transaction-api_1.1_spec-1.0.0.Final.jar
   jta-1.1.jar
   log4j-1.2.15.jar
   mysql-connector-java-5.1.18-bin.jar
   ognl-2.6.11.jar
   slf4j-api-1.6.1.jar
   slf4j-log4j12-1.6.1.jar
   struts2-core-2.1.6.jar
   struts2-fullhibernatecore-plugin-2.2.2-GA.jar
   xwork-2.1.2.jar
  </code></pre>
  
  <p>Also I implemented the quasi-fix listed in that thread by adding a “if (session == null)” check before some of the hibernate session calls. For example:</p>
  
  <pre><code>@SuppressWarnings("rawtypes")
  @Override
  public List getAllDepartments() {
      if (session == null) {
          System.out.println("****** CREATING SESSION ******");
          session = com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getNewSession();
          if (!session.isOpen()) {
              throw new NullPointerException("Fix the code: session's not here");
          }
          transaction = session.beginTransaction();
      }
  
      if(!session.isOpen()) {
              System.out.println("****** REOPENING SESSION ******");
  
              session = session.getSessionFactory().openSession();
              //session = com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getNewSession();
              transaction = session.beginTransaction();
      }
  
      return session.createQuery( "from Department" ).list();
  }
  </code></pre>
  
  <p>The second if I add to avoid a “org.hibernate.SessionException: Session is closed!” based on the above thread. </p>
  
  <p>This gets me passed the “java.lang.NullPointerException” and “org.hibernate.SessionException: Session is closed!” some of the times but this is inconsistent, if I keep refreshing the page it eventually comes back. </p>
  
  <p>Here is the stack trace for this new issue (you can see some of my print lines fomr the method above):</p>
  
  <pre><code>[DEBUG] com.opensymphony.xwork2.config.ConfigurationManager.debug:57 - Checking ConfigurationProviders for reload.
  [DEBUG] com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.debug:57 - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@29e03842], property=struts]
  [WARN ] com.opensymphony.xwork2.ognl.OgnlValueStack.warn:45 - Could not find property [struts.actionMapping]
  [DEBUG] com.opensymphony.xwork2.config.ConfigurationManager.debug:57 - Checking ConfigurationProviders for reload.
  [DEBUG] com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.debug:57 - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@29e03842], property=struts]
  [WARN ] com.opensymphony.xwork2.ognl.OgnlValueStack.warn:45 - Could not find property [struts.valueStack]
  [DEBUG] com.opensymphony.xwork2.config.ConfigurationManager.debug:57 - Checking ConfigurationProviders for reload.
  [DEBUG] com.opensymphony.xwork2.DefaultActionProxy.debug:57 - Creating an DefaultActionProxy for namespace / and action name crud
  [DEBUG] com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil.debug:57 - cannot find method [prepareSave] in action [com.aurifa.struts2.tutorial.action.EmployeeAction@4e8659a]
  [DEBUG] com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil.debug:57 - cannot find method [prepareDoSave] in action [com.aurifa.struts2.tutorial.action.EmployeeAction@4e8659a]
  ****** REOPENING SESSION ******
  Hibernate: select department0_.departmentId as departme1_1_, department0_.name as name1_ from test2.Department department0_
  ****** REOPENING SESSION ******
  Hibernate: select employee0_.employeeId as employeeId0_1_, employee0_.age as age0_1_, employee0_.departmentId as departme5_0_1_, employee0_.firstName as firstName0_1_, employee0_.lastName as lastName0_1_, department1_.departmentId as departme1_1_0_, department1_.name as name1_0_ from test2.Employee employee0_ left outer join test2.Department department1_ on employee0_.departmentId=department1_.departmentId where employee0_.employeeId=?
  [DEBUG] com.opensymphony.xwork2.interceptor.I18nInterceptor.debug:57 - intercept '//crud' { 
  [DEBUG] com.opensymphony.xwork2.interceptor.I18nInterceptor.debug:57 - before Locale=en_US
  [DEBUG] com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.debug:57 - Entering nullPropertyValue [target=[com.aurifa.struts2.tutorial.action.EmployeeAction@4e8659a, com.opensymphony.xwork2.DefaultTextProvider@29e03842], property=struts]
  [WARN ] com.opensymphony.xwork2.ognl.OgnlValueStack.warn:45 - Could not find property [struts]
  [DEBUG] org.apache.struts2.interceptor.FileUploadInterceptor.debug:57 - Bypassing //crud
  [DEBUG] com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.debug:57 - Setting static parameters {}
  [DEBUG] com.opensymphony.xwork2.interceptor.ParametersInterceptor.debug:57 - Setting params employee.age =&gt; [ 4 ] employee.department.departmentId =&gt; [ 1 ] employee.employeeId =&gt; [ 9 ] employee.firstName =&gt; [ dsadsa ] employee.lastName =&gt; [ dsads ] 
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: age
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.model.Employee
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - field-level type converter for property [age] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: employee.age
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.action.EmployeeAction
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - global-level type converter for property [age] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@62f3782]
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: departmentId
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.model.Department
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - field-level type converter for property [departmentId] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: employee.department.departmentId
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.model.Employee
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - global-level type converter for property [departmentId] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@62f3782]
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: employeeId
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.model.Employee
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - field-level type converter for property [employeeId] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: employee.employeeId
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.action.EmployeeAction
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - global-level type converter for property [employeeId] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@62f3782]
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: firstName
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.model.Employee
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - field-level type converter for property [firstName] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: employee.firstName
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.action.EmployeeAction
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - global-level type converter for property [firstName] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@62f3782]
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: lastName
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.model.Employee
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - field-level type converter for property [lastName] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Property: employee.lastName
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - Class: com.aurifa.struts2.tutorial.action.EmployeeAction
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - global-level type converter for property [lastName] = none found
  [DEBUG] com.opensymphony.xwork2.conversion.impl.XWorkConverter.debug:57 - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@62f3782]
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.intercept:151 - Preparing Injection Hibernate Session and Transaction process: /crud - Method: com.aurifa.struts2.tutorial.action.EmployeeAction.save()
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getSession:91 - Hibernate Session Required (from current Thread) - SessionFactory required: (default)
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getSession:98 - No Hibernate Session in current thread. New Hibernate Session will be created and returned (SessionFactory "(default)")
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getNewSession:153 - New Hibernate Session required - SessionFactory required: (default)
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getNewSession:167 - New Hibernate Session created and returned (SessionFactory "")
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.getHibernateSessionFromFactory:380 - Hibernate Session from Full Hibernate Plugin's Hibernate Session Factory
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.debugInfoSessionInjectedByAnnotation:508 - Hibernate Session injected (by annotation) into Action. Field "session". Class "com.rwblackburn.struts2.tutorial.dao.EmployeeHibernateDao"
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getSession:91 - Hibernate Session Required (from current Thread) - SessionFactory required: (default)
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getSession:125 - Existing Hibernate Session from current thread returned (SessionFactory "")
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.getHibernateSessionFromFactory:380 - Hibernate Session from Full Hibernate Plugin's Hibernate Session Factory
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.debugInfoSessionInjectedByAnnotation:508 - Hibernate Session injected (by annotation) into Action. Field "session". Class "com.rwblackburn.struts2.tutorial.dao.DepartmentHibernateDao"
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.debugInfoTransactionInjectedByAnnotation:599 - Hibernate Transaction injected (by annotation) into Action. Field "transaction". Class "com.rwblackburn.struts2.tutorial.dao.EmployeeHibernateDao"
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.debugInfoTransactionInjectedByAnnotation:599 - Hibernate Transaction injected (by annotation) into Action. Field "transaction". Class "com.rwblackburn.struts2.tutorial.dao.DepartmentHibernateDao"
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.intercept:77 - Full     Hibernate Plugin Validation in class com.aurifa.struts2.tutorial.action.EmployeeAction
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.intercept:116 - Full Hibernate Plugin Validation found no erros.
  [DEBUG] com.opensymphony.xwork2.DefaultActionInvocation.debug:57 - Executing action method = input
  [DEBUG] org.apache.struts2.dispatcher.ServletRedirectResult.debug:57 - Redirecting to finalLocation /test2/index.action
  Hibernate: update test2.Employee set age=?, departmentId=?, firstName=?, lastName=? where employeeId=?
  [DEBUG] com.opensymphony.xwork2.config.ConfigurationManager.debug:57 - Checking ConfigurationProviders for reload.
  [DEBUG] com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.debug:57 - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@29e03842], property=struts]
  [WARN ] com.opensymphony.xwork2.ognl.OgnlValueStack.warn:45 - Could not find property [struts.actionMapping]
  [DEBUG] com.opensymphony.xwork2.config.ConfigurationManager.debug:57 - Checking ConfigurationProviders for reload.
  [DEBUG] com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.debug:57 - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@29e03842], property=struts]
  [WARN ] com.opensymphony.xwork2.ognl.OgnlValueStack.warn:45 - Could not find property [struts.valueStack]
  [DEBUG] com.opensymphony.xwork2.config.ConfigurationManager.debug:57 - Checking ConfigurationProviders for reload.
  [DEBUG] com.opensymphony.xwork2.DefaultActionProxy.debug:57 - Creating an DefaultActionProxy for namespace / and action name index
  [DEBUG] com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil.debug:57 - cannot find method [prepareList] in action [com.aurifa.struts2.tutorial.action.EmployeeAction@7a23792b]
  [DEBUG] com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil.debug:57 - cannot find method [prepareDoList] in action [com.aurifa.struts2.tutorial.action.EmployeeAction@7a23792b]
  Hibernate: select department0_.departmentId as departme1_1_, department0_.name as name1_ from test2.Department department0_
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.commitHibernateTransaction:264 - Hibernate Transation  org.hibernate.transaction.JDBCTransaction@54ebb9ba rolledback by Full Hibernate Plugin
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.closeSession:207 - Hibernate Session closed
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.closeHibernateSession:275 - Hibernate Session closed by Full Hibernate Plugin's Hibernate Session Factory
  [DEBUG] com.opensymphony.xwork2.config.ConfigurationManager.debug:57 - Checking ConfigurationProviders for reload.
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.intercept:219 - Hibernate Transaction Committed
  [DEBUG] com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.intercept:238 - Injection Hibernate Session and Transaction process for /crud - Method: com.aurifa.struts2.tutorial.action.EmployeeAction.save() finished
  [DEBUG] com.opensymphony.xwork2.interceptor.I18nInterceptor.debug:57 - after Locale=en_US
  [DEBUG] com.opensymphony.xwork2.interceptor.I18nInterceptor.debug:57 - intercept } 
  </code></pre>
  
  <p>I am probably just missing the above session checking in one of my methods which uses the session. However at this point it seems that this can not possible be the answer, and I am either doing somthing very wrong or there is something missing somewhere.</p>
  
  <p>I can email anyone the WAR file of this test app (using Struts 2.1.6) if they need. Any help will be appreciated. </p>
  
  <p>Thank You</p>
  
  <p>PS: I did post this on the Plug-in support forum first, but got no response, so was hoping SO would be able to help me (isseu #36 on code.google.com/p/full-hibernate-plugin-for-struts2/issues) </p>