Grails
  1. Grails
  2. GRAILS-3713

UrlMapping reloading broken in 1.0.4 - ServletContext must not be null

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0.4
    • Fix Version/s: 1.0.5, 1.1-beta3
    • Component/s: Controllers
    • Labels:
      None
    • Testcase included:
      yes

      Description

      I am getting the following error when I make changes to UrlMappings and try to reload a page.
      java.lang.IllegalArgumentException: ServletContext must not be null

      This is Grails 1.0.4 on Windows, JDK 6

      For example (this sample app attached to the bug)

      class UrlMappings {
      static mappings = {
      "/urltest/$action?/$id?"

      { controller="urltest"; section="sectiontest" }


      }
      }

      class UrltestController {
      def index = {}
      }

      /views/urltest/index.gsp:
      <html>
      <head><title>Simple GSP page</title></head>
      <body>Section is $

      {params.section}

      </body>
      </html>

      If I change the Urlmapping line to the following and reload the page, I get an error.
      controller="urltest"; section="sectiontest2"

      Stopping and restarting the app works.

      I have verified the problem does not exist in 1.0.3.

      Thanks,

      Truncated Error page with stack trace:
      HTTP ERROR: 500

      ServletContext must not be null
      RequestURI=/urltest/urltest/index

      Caused by:

      java.lang.IllegalArgumentException: ServletContext must not be null
      at org.springframework.util.Assert.notNull(Assert.java:112)
      at org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(WebApplicationContextUtils.java:96)
      at org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(WebApplicationContextUtils.java:86)
      at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:68)
      at org.codehaus.groovy.grails.web.util.WebUtils.lookupApplication(WebUtils.java:113)
      at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.getMultipartDisabled(DefaultUrlMappingInfo.java:253)
      at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.tryMultipartParams(DefaultUrlMappingInfo.java:228)
      at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.checkDispatchAction(DefaultUrlMappingInfo.java:209)
      at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.getActionName(DefaultUrlMappingInfo.java:168)
      at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.populateParamsForMapping(DefaultUrlMappingInfo.java:138)
      at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.configure(DefaultUrlMappingInfo.java:155)

        Activity

        Hide
        Mingfai Ma added a comment -

        similar "ServletContext must not be null " problem exists in Grails 1.1 beta 2. I'm not too sure how exactly to repeat the problem, but I seem to have found a workaround by chance.

        for a newly created app, the following UrlMappings may likely to cause that exception:

           /"/"(controller : 'content', action : 'home') 
        

        but the following seem to be always working

            "/"() {controller = 'content'; action = 'home'}
        

        Notice that i've setup a web-jetty.xml and the context path is / rather than the default project name

        Show
        Mingfai Ma added a comment - similar "ServletContext must not be null " problem exists in Grails 1.1 beta 2. I'm not too sure how exactly to repeat the problem, but I seem to have found a workaround by chance. for a newly created app, the following UrlMappings may likely to cause that exception: / "/" (controller : 'content', action : 'home') but the following seem to be always working "/" () {controller = 'content'; action = 'home'} Notice that i've setup a web-jetty.xml and the context path is / rather than the default project name
        Hide
        Mingfai Ma added a comment -

        amendment - the first code block should be read as:

        "/"(controller : 'content', action : 'home')
        
        Show
        Mingfai Ma added a comment - amendment - the first code block should be read as: "/" (controller : 'content', action : 'home')
        Hide
        Graeme Rocher added a comment -

        Bulk closing bunch of resolved issues

        Show
        Graeme Rocher added a comment - Bulk closing bunch of resolved issues

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Eric Pederson
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development