title: The requested list key 'userRegisterTO.countryList' could not be resolved
body: <p>I was working with Struts 2.0 , Hibernate and JPA . But i got this strage error on my jsp page so please help me if you have any solution for the above problem please find the action class detail. In action class i am getting the value of <code>userRegisterTO</code> object and complete <code>countryList</code> but on jsp <code>userRegisterTO</code> can not be resolved . So please help what am i doing wrong.</p>
  
  <p>Action class</p>
  
  <pre><code>public class UserRegistrationAction extends ActionSupport {
      private UserRegisterInterface userRegisterInterface = new UserRegisterService();
      public UserRegisterTO userRegisterTO = null;
      public String registerUser() {
          userRegisterTO = new UserRegisterTO(); 
          this.userRegisterTO = this.userRegisterInterface.listCountryName();
          System.out.println("The size of the list is -  ------ = "+userRegisterTO.getCountryList().size());
          return SUCCESS;
      }
  </code></pre>
  
  <p>Note - in SOP i getting the size of the list but on jsp userRegisterTO can not be resolved</p>
  
  <p>JSP</p>
  
  <pre><code>&lt;s:form action="/admin/test"&gt;
      &lt;s:textfield label="Please enter your name" name="name"/&gt;
      &lt;s:submit/&gt;
      &lt;s:select list="userRegisterTO.countryList" 
          listkey="id" 
          listvalue="countryName"/&gt;
  &lt;/s:form&gt;
  </code></pre>
  
  <p>UserRegisterTO </p>
  
  <pre><code>public class UserRegisterTO 
  { 
    public List&lt;Country&gt; countryList = new ArrayList&lt;Country&gt;(); 
    public List&lt;Country&gt; getCountryList() 
    { 
     return countryList; 
     } 
    public void setCountryList(List&lt;Country&gt; countryList) { 
      this.countryList = countryList;
     } 
  </code></pre>
  
  <hr>
  
  <p>My action class</p>
  
  <pre><code>/**
   * 
   */
  package com.castle.user.register.action;
  import com.castle.user.register.service.UserRegisterInterface;
  import com.castle.user.register.service.UserRegisterService;
  import com.castle.user.register.service.UserRegisterTO;
  import com.opensymphony.xwork2.ActionSupport;
  
  /**
   * @author Rahul
   *
   */
  public class UserRegistrationAction extends ActionSupport {
  
      private UserRegisterInterface userRegisterInterface = new UserRegisterService();
      private UserRegisterTO userRegisterTO = null;
      public String registerUser(){
           //userRegisterTO = new UserRegisterTO(); 
          this.userRegisterTO = this.userRegisterInterface.listCountryName();
          System.out.println("The size of the list is -  ------ = "+userRegisterTO.getCountryList().size());
          return SUCCESS;
      }
      public UserRegisterTO getUserRegisterTO() {
          return userRegisterTO;
      }
      public void setUserRegisterTO(UserRegisterTO userRegisterTO) {
          this.userRegisterTO = userRegisterTO;
      }
  
  
  }
  </code></pre>
  
  <p>My service class</p>
  
  <pre><code>/**
   * 
   */
  package com.castle.user.register.service;
  
  import java.util.List;
  
  import com.castle.model.Country;
  import com.castle.user.dao.UserRegisterDAO;
  import com.castle.user.dao.UserRegisterDAOInterface;
  
  /**
   * @author Rahul
   *
   */
  public class UserRegisterService implements UserRegisterInterface{
  
      private UserRegisterDAOInterface userRegisterDAOInterface = new UserRegisterDAO();
  
      @Override
      public UserRegisterTO listCountryName() {
          List&lt;Country&gt; countryList = null;
          UserRegisterTO userRegisterTO = new UserRegisterTO();
          try{
              countryList = this.userRegisterDAOInterface.countryList();
              userRegisterTO.setCountryList(countryList);
          }catch(Exception e){
              e.printStackTrace();
          }
          return userRegisterTO;
      }
  
  }
  </code></pre>
  
  <p>My dao class</p>
  
  <pre><code>/**
   * 
   */
  package com.castle.user.dao;
  
  import java.util.List;
  
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.Persistence;
  import javax.persistence.Query;
  
  import com.castle.model.Country;
  
  /**
   * @author Rahul
   *
   */
  public class UserRegisterDAO implements UserRegisterDAOInterface {
      private EntityManagerFactory entityManagerFactory;
      private EntityManager entityManager;
  
      public UserRegisterDAO() {
          this.entityManagerFactory = Persistence
                  .createEntityManagerFactory("blogds");
          this.entityManager = entityManagerFactory.createEntityManager();
      }
  
      @Override
      public List&lt;Country&gt; countryList() {
          List&lt;Country&gt; countryList = null;
          String query =null;
          Query q =null;
          try{
              query = "select c from com.castle.model.Country c";
              countryList = (List&lt;Country&gt;)entityManager.createQuery(query).getResultList();
  
          }catch(Exception e){
              e.printStackTrace();
          }
          return countryList;
      }
  
  }
  </code></pre>
  
  <p>action.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  
  &lt;struts&gt;
  
  &lt;package name="user" namespace="/user/registration" extends="struts-default"&gt;
      &lt;action name="registerUser" class="com.castle.user.register.action.UserRegistrationAction" method="registerUser"&gt;
          &lt;result name="input"&gt;/index.jsp&lt;/result&gt;
          &lt;result name="success" type="redirect"&gt;/jsp/register/register.jsp&lt;/result&gt;
      &lt;/action&gt;
  &lt;/package&gt;
  
  &lt;/struts&gt;
  </code></pre>
  
  <p>my jsp -</p>
  
  <pre><code>&lt;%@include file="/header.jsp"%&gt;
  &lt;s:form action="/admin/test"&gt;
      &lt;s:textfield label="Please enter your name" name="name"/&gt;
      &lt;s:submit/&gt;
      &lt;s:select list="userRegisterTO.countryList" 
          listkey="id" 
          listvalue="countryName"&gt;&lt;/s:select&gt;
  
  &lt;/s:form&gt;
  &lt;%@include file="/footer.jsp"%&gt;
  </code></pre>
  
  <p>still the problem is same please provide and work around</p>