11

Despite searching the plugin docs and general searching, I can't find an answer to this one. The closest I've gotten is the end of this page, which seems to describe setting a Tomcat timeout. There is an entire section of the plugin docs titled "Configuration Settings Now in Config.groovy", is there no way to configure timeout for the plugin without involving the container's settings?

Josh Diehl
  • 2,913
  • 2
  • 31
  • 43

1 Answers1

20

The plugin doesn't have settings for session duration - it just uses whatever is configured for the whole app. You can do this by editing web.xml (run grails install-templates if you haven't yet) and edit src/templates/war/web.xml. Add

<session-config>
   <session-timeout>30</session-timeout>
</session-config>

before the welcome-file-list element and set the session-timeout value to whatever number of minutes you want it to be.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
  • Does this approach work for non-Tomcat containers? I know very little about what happens with Grails apps once they get war'ed up. – Josh Diehl Jul 27 '12 at 19:04
  • 4
    Yes, the web.xml file is read by all containers since it's part of the servlet spec. Containers often also have container-specific descriptors, e.g. jboss-web.xml, but those are in addition to web.xml – Burt Beckwith Jul 27 '12 at 20:22
  • @BurtBeckwith I thought Grails includes web.xml? It `install-templates` required? – raffian Jan 27 '14 at 21:15
  • 4
    If you don't run `install-templates` Grails uses the default template that's part of the installed Grails distro. When you run `install-templates` they get copied to your app, and those are used instead. – Burt Beckwith Jan 27 '14 at 23:34
  • @BurtBeckwith After doing `install-templates`, is it ok to remove everything in `web.xml` and leave only the timeout setting, then move the file to `web-app/WEB-INF`, right? – raffian Jan 28 '14 at 01:56
  • No, don't delete anything unless you have a good reason and know what you're doing. Everything there is included in the final file, plus extra elements added by Grails and plugins – Burt Beckwith Jan 28 '14 at 02:02
  • Hi Burt, I am using grails 2.3.7. I have installed the templates and made the changes as you mentioned. After generating the war file, I checked up the contents of the war. The changes do reflect in the war file. However session timeout does not occur. – Rammohan Dec 16 '14 at 17:28
  • 1
    See this link for how to set session timeout for grails 3 applications http://nimavat.me/code-snippets/grails3-session-timeout – Sudhir N Jul 30 '17 at 16:07