title: Shiro session timeout shows an error: There is no session with id using Struts2
body: <p>I have this codes using Shiro:</p>
  
  <p>LoginAction.java:</p>
  
  <pre><code>@Action(value = "loginUser", results = { @Result(name = "error", type = "tiles", location = "error") })
  public String loginRegisterUser() {
  
      String retStr = null;
  
      Subject currentUser = SecurityUtils.getSubject();
      UsernamePasswordToken token = new UsernamePasswordToken(loginUser.getUserName(),loginUser.getUserPassword());
      token.setRememberMe(true);
  
      try {           
  
          Session session = currentUser.getSession();
  
          session.setAttribute("USERID", loginUser.getUserName());
          session.setAttribute("SESSIONID", session.getId());
  
          System.out.println("USERID: " + session.getAttribute("USERID"));
          System.out.println("SESSIONID: " + session.getAttribute("SESSIONID"));
  
          // session.setAttribute("LOGINUSER", loginUser); //TODO by Carmela: Add Resource Details
          sessionAttributes.put("USERID", session.getAttribute("USERID"));
          sessionAttributes.put("SESSIONID", session.getAttribute("SESSIONID"));
  
          currentUser.login(token);
  
          session.stop();
          currentUser.getSession(true);
  
          if (currentUser.isAuthenticated()) {
              session = currentUser.getSession(false);
              session.touch();
  
              session.setAttribute("USERID", sessionAttributes.get("USERID"));
              session.setAttribute("SESSIONID", sessionAttributes.get("SESSIONID"));
  
              System.out.println("user is authenticated!!!!!");
              System.out.println("isAuthenticated USERID: " + session.getAttribute("USERID"));
              System.out.println("isAuthenticated SESSIONID: " + session.getAttribute("SESSIONID"));
  
              session.setTimeout(30000);
  
              retStr = "loginUserSuccess";
          }
      } catch (ExpiredSessionException e) {
          System.out.println("LoginAction ExpiredSessionException");
      } catch (UnknownAccountException uae) {
          addActionError("Unknown account.");
          retStr = "loginUserLogin";
          uae.printStackTrace();
      } catch (IncorrectCredentialsException iae) {
          addActionError("Incorrect Username and Password.");
          retStr = "loginUserLogin";
          iae.printStackTrace();
      } catch (LockedAccountException lae) {
          addActionError("Your account has been locked.");
          retStr = "loginUserLogin";
          lae.printStackTrace();
      } catch (AuthenticationException ae) {
          addActionError("Enter Valid Username or Password");
          retStr = "loginUserLogin";
          ae.printStackTrace();
      } catch (Exception e) {
          addActionError("Error!");
          retStr = "loginUserLogin";
          e.printStackTrace();
      }
  
      return retStr;
  }
  </code></pre>
  
  <p>shiro.ini:</p>
  
  <pre><code>[main]
  shiro.loginUrl = /login.jsp
  ldapRealm = org.apache.shiro.realm.ldap.JndiLdapRealm
  ldapRealm.userDnTemplate = uid={0},ou=users,dc=example,dc=com
  ldapRealm.contextFactory.url = ldap://10.62.24.210:10389
  ldapRealm.contextFactory.systemUsername = something
  ldapRealm.contextFactory.systemPassword = password
  ldapRealm.contextFactory.authenticationMechanism = simple
  ldapRealm.authorizationCachingEnabled = false
  </code></pre>
  
  <p>Whenever my session timesout after 30 seconds and hit the same url, it shows me the<br>
      error:</p>
  
  <pre><code>Messages: Session with id [6944e751-96bd-49ad-aab9-66ed42da4c9c] has expired. Last 
  access time: 2/19/14 6:00 PM. Current time: 2/19/14 6:03PM. Session timeout is set to  
  30 seconds (0 minutes) 
  File: org/apache/shiro/session/mgt/SimpleSession.java
  </code></pre>
  
  <p>When I hit again the same url, it shows me this message:</p>
  
  <pre><code>Messages: There is no session with id [6944e751-96bd-49ad-aab9-66ed42da4c9c] 
  File: org/apache/shiro/session/mgt/eis/AbstractSessionDAO.java
  </code></pre>
  
  <p>Can anyone help me? Thanks in advance.</p>