Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 1.0.4
-
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?"
}
}
class UrltestController {
def index = {}
}
/views/urltest/index.gsp:
<html>
<head><title>Simple GSP page</title></head>
<body>Section is $
</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)
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