grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.78k stars 950 forks source link

GRAILS-1721: ClassCastException at GrailsParameterMap.java:80 #7357

Closed graemerocher closed 9 years ago

graemerocher commented 17 years ago

Original Reporter: dbwhitaker Environment: Not Specified Version: 1.0-RC1 Migrated From: http://jira.grails.org/browse/GRAILS-1721

This exception occurs when: 1 the 'name' parameter value in a form contains a '.' character; AND 2) the name does not conform to the "expected" naming convention for multidimensional parameters. In my case my GSP contained a 'textarea' with name='flow.block.myTextFlow" even though the this not part of a multidimensional naming scheme. I was able to work around this issue by changing my own 'separator" character from '.' to ''. (In other words there is no exception if I changed to name='flow_block_myTextFlow")

An argument could be made that this issue is not a bug and the remedy is simply to avoid using the '.' character in tags that are not multi-dimensional. (And documenting this restriction.) It would of course be preferable to modify the code to be "defensive" and not throw an exception if the '.' in a tag name is not part of a multidimensional parameter map.

Here's the top of the stack from the exception:

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map at org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap.processNestedKeys(GrailsParameterMap.java:80) at org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap.processNestedKeys(GrailsParameterMap.java:89) at org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap.(GrailsParameterMap.java:54) at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest.getParams(GrailsWebRequest.java:127) at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingInfo.configure(DefaultUrlMappingInfo.java:113) at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089) at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119) at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089) at org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletF ilter.java:155) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089) at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.jav a:54) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:183) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089) ...

graemerocher commented 16 years ago

graemerocher said: Can you provide an example GSP?

graemerocher commented 16 years ago

dbwhitaker said: I apologize but I am not currently able to create an example that will this exception. I encountered this error in an application with a complex domain model. I spent some time today trying to build a simpler model that would reproduce this error but failed. My app has changed in the past month and I don't seem to be able to recreate this problem at all. Sorry.