WebXML Plugin
  1. WebXML Plugin
  2. GPWEBXML-9

Since Grails 2.1.1 - Seems to create a new session-config nodes in the xml instead of replacing the session-timeout value

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Grails-Web-Xml 1.4.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Grails 2.1.1

      Description

      Creates a empty grails project (grails create-app test)
      Go to test folder
      Installs the webxml plugin (grails install-plugin webxml)
      Generates the WebXmlConfig file (grails create-web-xml-config)
      Uncomments the sessionConfig.sessionTimeout configuration in the grails-app/conf/WebXmlConfig.groovy
      Runs the application (grails run-app)

      I got this exception

      | Loading Grails 2.1.1
      | Configuring classpath.
      | Environment set to development.....
      | Packaging Grails application....
      | Compiling 1 source files.....
      | Running Grails application
      | Error 2012-09-17 19:20:40,188 [localhost-startStop-1] ERROR digester.Digester  - Begin event threw exception
      Message: <session-config> element is limited to 1 occurrence
          Line | Method
      ->>  501 | startElement     in com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      |   1363 | scanStartElement in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
      |   2756 | next . . . . . . in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver
      |    647 | next             in com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl
      |    511 | scanDocument . . in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
      |    808 | parse            in com.sun.org.apache.xerces.internal.parsers.XML11Configuration
      |    737 | parse . . . . .  in     ''
      |    119 | parse            in com.sun.org.apache.xerces.internal.parsers.XMLParser
      |   1205 | parse . . . . .  in com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
      |    522 | parse            in com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
      |    303 | innerRun . . . . in java.util.concurrent.FutureTask$Sync
      |    138 | run              in java.util.concurrent.FutureTask
      |    886 | runTask . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
      |    908 | run              in     ''
      ^    662 | run . . . . . .  in java.lang.Thread
      | Error 2012-09-17 19:20:40,219 [localhost-startStop-1] ERROR startup.ContextConfig  - Parse error in application web.xml file at file:/C:/Users/SGUIMONT/.grails/2.1.1/projects/test/resources/web.xml
      Message: Error at (195, 21) : <session-config> element is limited to 1 occurrence
          Line | Method
      ->>  501 | startElement     in com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      |   1363 | scanStartElement in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
      |   2756 | next . . . . . . in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver
      |    647 | next             in com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl
      |    511 | scanDocument . . in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
      |    808 | parse            in com.sun.org.apache.xerces.internal.parsers.XML11Configuration
      |    737 | parse . . . . .  in     ''
      |    119 | parse            in com.sun.org.apache.xerces.internal.parsers.XMLParser
      |   1205 | parse . . . . .  in com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
      |    522 | parse            in com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
      |    303 | innerRun . . . . in java.util.concurrent.FutureTask$Sync
      |    138 | run              in java.util.concurrent.FutureTask
      |    886 | runTask . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
      |    908 | run              in     ''
      ^    662 | run . . . . . .  in java.lang.Thread
      
      Caused by IllegalArgumentException: <session-config> element is limited to 1 occurrence
      ->>  501 | startElement     in com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
      |   1363 | scanStartElement in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
      |   2756 | next . . . . . . in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver
      |    647 | next             in com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl
      |    511 | scanDocument . . in com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
      |    808 | parse            in com.sun.org.apache.xerces.internal.parsers.XML11Configuration
      |    737 | parse . . . . .  in     ''
      |    119 | parse            in com.sun.org.apache.xerces.internal.parsers.XMLParser
      |   1205 | parse . . . . .  in com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
      |    522 | parse            in com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
      |    303 | innerRun . . . . in java.util.concurrent.FutureTask$Sync
      |    138 | run              in java.util.concurrent.FutureTask
      |    886 | runTask . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
      |    908 | run              in     ''
      ^    662 | run . . . . . .  in java.lang.Thread
      | Error 2012-09-17 19:20:40,219 [localhost-startStop-1] ERROR startup.ContextConfig  - Occurred at line 195 column 21
      

        Activity

        Hide
        Sebastien Guimont added a comment -

        I made a small patch in the WebxmlGrailsPlugin.groovy of the webxml plugin, but is not a complete solution (it's works for me). The problem is I removed the old node instead of replacing the value of the session-timeout element.

        		//session Timeout
        		if (config.sessionConfig.sessionTimeout instanceof Integer) {
        			def sessionConfig = xml."session-config"
        			if(sessionConfig) {
        				xml.removeChild(sessionConfig[0])
        			}
        			
        			def contextParam = xml."context-param"
        			contextParam[contextParam.size() - 1] + {
        				'session-config'{
        					'session-timeout'(config.sessionConfig.sessionTimeout)
        				}
        			}
        		}
        
        
        Show
        Sebastien Guimont added a comment - I made a small patch in the WebxmlGrailsPlugin.groovy of the webxml plugin, but is not a complete solution (it's works for me). The problem is I removed the old node instead of replacing the value of the session-timeout element. //session Timeout if (config.sessionConfig.sessionTimeout instanceof Integer ) { def sessionConfig = xml. "session-config" if (sessionConfig) { xml.removeChild(sessionConfig[0]) } def contextParam = xml. "context-param" contextParam[contextParam.size() - 1] + { 'session-config'{ 'session-timeout'(config.sessionConfig.sessionTimeout) } } }
        Hide
        Marcel Overdijk added a comment -

        Hit this one as well with Grails 2.1.1.

        I wonder if this is caused by a regression in Grails 2.1.1 as this plugin hasn't been updated for 7 months.

        Might be interesting to move some parts this plugin does to Grails core. E.g like setting the session timeout without installing the templates.

        Show
        Marcel Overdijk added a comment - Hit this one as well with Grails 2.1.1. I wonder if this is caused by a regression in Grails 2.1.1 as this plugin hasn't been updated for 7 months. Might be interesting to move some parts this plugin does to Grails core. E.g like setting the session timeout without installing the templates.
        Hide
        Burt Beckwith added a comment -

        As of 2.1 the web.xml templates contain a session-config element. So until this is fixed, run the install-templates script and edit src/templates/war/web.xml instead of using the sessionTimeout config option.

        Show
        Burt Beckwith added a comment - As of 2.1 the web.xml templates contain a session-config element. So until this is fixed, run the install-templates script and edit src/templates/war/web.xml instead of using the sessionTimeout config option.
        Hide
        Goran Ehrsson added a comment -

        In Grails 2.1.1, the default web.xml have a session-timeout element. This makes life complicated.
        Adding sessionConfig.sessionTimeout in WebXmlConfig.groovy creates a duplicate session-timeout element and the application refuse to start.
        Another problem is that it's now impossible to configure default session timeout in tomcat/conf/web.xml since Grails always includes a session-timeout element.

        Configuring session-timeout in Grails 2.1.1 is overly complex, you have to do one of the following:
        1. grails install-templates, remove session-timeout from web.xml, add timeout in WebXmlConfig.groovy
        2. grails install-templates, remove session-timeout from web.xml, set timeout in tomcat/conf/web.xml
        3. grails install-templates, change session-timeout in web.xml

        Can we please remove session-timeout from the default generated web.xml? that would solve both issues.

        http://grails.1312388.n4.nabble.com/Not-able-to-change-session-timeout-using-webxml-plugin-anymore-Grails-2-1-1-td4636267.html
        http://grails.1312388.n4.nabble.com/web-xml-lt-session-timeout-gt-30-lt-session-timeout-gt-td4638625.html

        Show
        Goran Ehrsson added a comment - In Grails 2.1.1, the default web.xml have a session-timeout element. This makes life complicated. Adding sessionConfig.sessionTimeout in WebXmlConfig.groovy creates a duplicate session-timeout element and the application refuse to start. Another problem is that it's now impossible to configure default session timeout in tomcat/conf/web.xml since Grails always includes a session-timeout element. Configuring session-timeout in Grails 2.1.1 is overly complex, you have to do one of the following: 1. grails install-templates, remove session-timeout from web.xml, add timeout in WebXmlConfig.groovy 2. grails install-templates, remove session-timeout from web.xml, set timeout in tomcat/conf/web.xml 3. grails install-templates, change session-timeout in web.xml Can we please remove session-timeout from the default generated web.xml? that would solve both issues. http://grails.1312388.n4.nabble.com/Not-able-to-change-session-timeout-using-webxml-plugin-anymore-Grails-2-1-1-td4636267.html http://grails.1312388.n4.nabble.com/web-xml-lt-session-timeout-gt-30-lt-session-timeout-gt-td4638625.html

          People

          • Assignee:
            Burt Beckwith
            Reporter:
            Sebastien Guimont
          • Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated: