1

I'm running a grails 1.3.9 application in Netbeans 7.1.1 IDE, and would like to decrease the session timeout for testing purposes. My prolem is I can't find a server.xml file under neither the NetBeansProjects nor the NetBeans folders. Is it located elsewhere or is it named differently ?

Thanks

2 Answers 2

1

You can also alter the build of the web.xml file with a groovy script '_Events.groovy' in the '/script' directory. You can use the 'eventWebXmlEnd' event to add your configuration:

import grails.util.Environment
import groovy.xml.StreamingMarkupBuilder

eventWebXmlEnd = { String tmpfile ->

    def root = new XmlSlurper().parse(webXmlFile)

    if(Environment.getCurrent() == 'TEST' ) {

        root.appendNode {

             'session-config' { 'session-timeout' (120) }

        }
    }

    webXmlFile.text = new StreamingMarkupBuilder().bind {

        mkp.declareNamespace("": "http://java.sun.com/xml/ns/javaee")

        mkp.yield(root)

    }
}
3
  • And does this require to run the install-template command previously ? Thanks.
    – xain
    Jun 29, 2012 at 13:51
  • I edited my answer. The last part was missing.. No, this solution doesn't require to install the templates...
    – peddn
    Jun 29, 2012 at 13:53
  • The application starts but tomcat doesn't recognize its context root once I added the script.
    – xain
    Jun 29, 2012 at 14:10
0

The session timeout is handled in the web.xml. You need to run grails install-templates which will give you a web.xml that you can manipulate. See the docs here.

You would add this to your web.xml

<session-config>
  <session-timeout>120</session-timeout>
</session-config>
1
  • Thanks for your reply. But this would affect the "production" war, I want that one to have the server's default timeout all the time. What I need is only the one I run in my test environmet to have a short timeout (and I don't want to micromanage it by changing the file's timeout everytime I generate the war).
    – xain
    Jun 29, 2012 at 13:37

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.