ICEfaces
  1. ICEfaces
  2. ICE-4929

Cannot change the session-timeout to an indefinite period

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 1.8.1
    • Fix Version/s: None
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Linux 2.6.18-92.el5 Oracle Unbreakable Linux
      Glassfish 2.1

      Description

      For our application, we don't want to set the session timeout in the web.xml file. We want to support the following, using the HttpSession.setMaxInactiveInterval method:

      1) when a user is not logged into our system (ie, displaying the login page), we're defining a default timeout period of 30 minutes (a value of 1800 into the setMaxInactiveInternal method)
      2) once a user has successfully logged into our web application, we want to define it to a custom value, or if none defined default to an indefinate period

      So, once the user successfully logs in, our application checks for a local setting. If none is provided, the application will default to indefinite timeouts by passing a -1 to the setMaxInactiveInternal method for the HttpSession.

      However, the value never stays set to -1. It is always being set back to 1800. If a positive value is defined, then it does not get set back to 1800

        Activity

        Hide
        Ed Hillmann added a comment -

        I've looked into this, and have a solution that works for me. It looks like the Monitor.isExpired() method is causing my grief. It was

        public boolean isExpired() {

        long elapsedInterval = System.currentTimeMillis() - lastAccess;
        try {
        int maxInterval = session.getMaxInactiveInterval();
        // 4496 return true if session is already expired
        Object o = session.getAttribute(POSITIVE_SESSION_TIMEOUT);

        // Try to reset the max session timeout if it is -1 from a Failover on Tomcat...
        // But if it was originally negative, it should stay that way.
        if (maxInterval > 0) {
        if (o == null)

        { session.setAttribute(POSITIVE_SESSION_TIMEOUT, new Integer(maxInterval)); }

        } else {
        if (o != null)

        { maxInterval = ((Integer) o).intValue(); session.setMaxInactiveInterval(maxInterval); }

        }
        return elapsedInterval + 15000 > maxInterval * 1000;
        } catch (Exception e)

        { return true; }

        }

        So, the monitor is persisting the original value in the POSITIVE_SESSION_TIMEOUT session attribute. From the comments, it looks to be added to cater for behaviour in Tomcat, for when a Tomcat failover occurs . So, based on that, there is an instance where an application has a positive timeout and the Tomcat server hosting fails and the session gets moved to another Tomcat server which doesn't have the correct timeout set up. So this remedys it.

        But, it is directly keeping me from what I want to do. And my application is running in Glassfish, not Tomcat and I don't anticipate using failover (for other reasons related to my application, not ICEfaces).

        So, I will submit a patch that does the following:

        • Defines a MonitorFactory class. It contains a single method, createMonitor. If the serverInfo for the HttpSession returns a Glassfish server, then a new instance of GlassfishMonitor is reused. Otherwise, the default Monitor is used.
        • GlassfishMonitor extends Monitor, but overrides the isExpired method. It doesn't try to restore the session timeout from a session attribute. It just gets it and checks it against the elapsedInterval.

        I thought this might be a good direction, as it looks like the Monitor might want to behave differently based on the Servlet Container hosting it. I haven't tried this out in Tomcat or any other container. But, this does allow my Glassfish server to behave the way I want without having to cater for workarounds added to support another container I'm not using.

        Show
        Ed Hillmann added a comment - I've looked into this, and have a solution that works for me. It looks like the Monitor.isExpired() method is causing my grief. It was public boolean isExpired() { long elapsedInterval = System.currentTimeMillis() - lastAccess; try { int maxInterval = session.getMaxInactiveInterval(); // 4496 return true if session is already expired Object o = session.getAttribute(POSITIVE_SESSION_TIMEOUT); // Try to reset the max session timeout if it is -1 from a Failover on Tomcat... // But if it was originally negative, it should stay that way. if (maxInterval > 0) { if (o == null) { session.setAttribute(POSITIVE_SESSION_TIMEOUT, new Integer(maxInterval)); } } else { if (o != null) { maxInterval = ((Integer) o).intValue(); session.setMaxInactiveInterval(maxInterval); } } return elapsedInterval + 15000 > maxInterval * 1000; } catch (Exception e) { return true; } } So, the monitor is persisting the original value in the POSITIVE_SESSION_TIMEOUT session attribute. From the comments, it looks to be added to cater for behaviour in Tomcat, for when a Tomcat failover occurs . So, based on that, there is an instance where an application has a positive timeout and the Tomcat server hosting fails and the session gets moved to another Tomcat server which doesn't have the correct timeout set up. So this remedys it. But, it is directly keeping me from what I want to do. And my application is running in Glassfish, not Tomcat and I don't anticipate using failover (for other reasons related to my application, not ICEfaces). So, I will submit a patch that does the following: Defines a MonitorFactory class. It contains a single method, createMonitor. If the serverInfo for the HttpSession returns a Glassfish server, then a new instance of GlassfishMonitor is reused. Otherwise, the default Monitor is used. GlassfishMonitor extends Monitor, but overrides the isExpired method. It doesn't try to restore the session timeout from a session attribute. It just gets it and checks it against the elapsedInterval. I thought this might be a good direction, as it looks like the Monitor might want to behave differently based on the Servlet Container hosting it. I haven't tried this out in Tomcat or any other container. But, this does allow my Glassfish server to behave the way I want without having to cater for workarounds added to support another container I'm not using.
        Hide
        Ed Hillmann added a comment - - edited

        I've cleaned this up, so there's no duplication of code. The previous one had problems with it. Use the v2 patch instead of the first one

        Show
        Ed Hillmann added a comment - - edited I've cleaned this up, so there's no duplication of code. The previous one had problems with it. Use the v2 patch instead of the first one
        Hide
        Ed Hillmann added a comment -

        With the changes made for ICE-4939, these changes are not necessary. Defining a value of -1 will make a session indefinate. This issue can be closed.

        Show
        Ed Hillmann added a comment - With the changes made for ICE-4939 , these changes are not necessary. Defining a value of -1 will make a session indefinate. This issue can be closed.
        Hide
        Ed Hillmann added a comment -

        Hello. My previous comment thought that ICE-4939 fixed this. But we've encountered it using 1.8.2 EE Patch 1. We've been able to apply the same patch already assigned to this issue to fix this. So, my request to close this issue was premature. We're still encountering this problem on unpatched releases of ICEfaces. Thanks.

        Show
        Ed Hillmann added a comment - Hello. My previous comment thought that ICE-4939 fixed this. But we've encountered it using 1.8.2 EE Patch 1. We've been able to apply the same patch already assigned to this issue to fix this. So, my request to close this issue was premature. We're still encountering this problem on unpatched releases of ICEfaces. Thanks.
        Hide
        Ken Fyten added a comment -

        Marking as Closed / Invalid as part of legacy ICEfaces 1.x, 2.x JIRA cleanup.

        Note: This issue may be resolved in a newer ICEfaces release, available here: http://www.icesoft.org/java/downloads/icefaces-downloads.jsf

        If the issue persists with the current ICEfaces release, please create a new JIRA for it.

        Show
        Ken Fyten added a comment - Marking as Closed / Invalid as part of legacy ICEfaces 1.x, 2.x JIRA cleanup. Note: This issue may be resolved in a newer ICEfaces release, available here: http://www.icesoft.org/java/downloads/icefaces-downloads.jsf If the issue persists with the current ICEfaces release, please create a new JIRA for it.

          People

          • Assignee:
            Unassigned
            Reporter:
            Ed Hillmann
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: