Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.2 final
-
Fix Version/s: 1.2.1
-
Component/s: None
-
Labels:None
-
Testcase included:yes
Description
When requesting the root of my project (eg, http://localhost:8080/mapper/), in Grails 1.1.1 my filters got executed, which are responsible for loading things from the database so that it's available in the Grails view. However, in Grails 1.2.0, the filter is not triggered anymore!
I've made two projects: mapper and mapper2.0. The mapper is a Grails 1.1.1 project, which prints a hello to the console for each request. The Mapper 2.0 does the same, but for some reason it's not triggered when requesting /, and therefore doesn't print 'hello'.
I hope this can be fixed, though a workaround would also be quite welcome for now!
Attachments
-
$i18n.getText("admin.common.words.hide")
- mapper.zip
- 03/Jan/10 5:21 AM
- 146 kB
- Erik Pragt
-
- mapper/.classpath 6 kB
- mapper/.project 0.5 kB
- mapper/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- mapper/application.properties 0.1 kB
- mapper/build.xml 5 kB
- mapper/grails-app/conf/BootStrap.groovy 0.1 kB
- mapper/grails-app/conf/Config.groovy 3 kB
- mapper/grails-app/conf/DataSource.groovy 0.6 kB
- mapper/grails-app/.../ExampleFilters.groovy 0.2 kB
- mapper/grails-app/.../resources.groovy 0.0 kB
- mapper/grails-app/.../UrlMappings.groovy 0.2 kB
- mapper/grails-app/.../messages.properties 3 kB
- mapper/grails-app/.../messages_de.properties 3 kB
- mapper/grails-app/.../messages_es.properties 3 kB
- mapper/grails-app/.../messages_fr.properties 2 kB
- mapper/grails-app/.../messages_it.properties 2 kB
- mapper/grails-app/.../messages_ja.properties 2 kB
- mapper/grails-app/.../messages_nl.properties 3 kB
- mapper/.../messages_pt_BR.properties 3 kB
- mapper/grails-app/.../messages_ru.properties 4 kB
- mapper/grails-app/.../messages_th.properties 5 kB
- mapper/.../messages_zh_CN.properties 2 kB
- mapper/grails-app/views/error.gsp 2 kB
- mapper/grails-app/views/index.gsp 0.9 kB
- mapper/grails-app/views/layouts/main.gsp 0.7 kB
- mapper/ivy.xml 2 kB
- mapper/ivysettings.xml 0.8 kB
- mapper/mapper-test.launch 0.8 kB
- mapper/mapper.launch 2 kB
- mapper/mapper.tmproj 2 kB
-
$i18n.getText("admin.common.words.hide")
- mapper2.zip
- 03/Jan/10 5:21 AM
- 176 kB
- Erik Pragt
-
- mapper2.0/.classpath 6 kB
- mapper2.0/.project 0.5 kB
- mapper2.0/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- mapper2.0/application.properties 0.2 kB
- mapper2.0/build.xml 5 kB
- mapper2.0/grails-app/.../BootStrap.groovy 0.1 kB
- mapper2.0/grails-app/conf/Config.groovy 3 kB
- mapper2.0/grails-app/.../DataSource.groovy 0.6 kB
- mapper2.0/.../ExampleFilters.groovy 0.2 kB
- mapper2.0/grails-app/.../resources.groovy 0.0 kB
- mapper2.0/grails-app/.../UrlMappings.groovy 0.2 kB
- mapper2.0/grails-app/.../messages.properties 3 kB
- mapper2.0/.../messages_de.properties 3 kB
- mapper2.0/.../messages_es.properties 3 kB
- mapper2.0/.../messages_fr.properties 2 kB
- mapper2.0/.../messages_it.properties 2 kB
- mapper2.0/.../messages_ja.properties 2 kB
- mapper2.0/.../messages_nl.properties 3 kB
- mapper2.0/.../messages_pt_BR.properties 3 kB
- mapper2.0/.../messages_ru.properties 4 kB
- mapper2.0/.../messages_th.properties 5 kB
- mapper2.0/.../messages_zh_CN.properties 2 kB
- mapper2.0/grails-app/views/error.gsp 2 kB
- mapper2.0/grails-app/views/index.gsp 0.9 kB
- mapper2.0/grails-app/.../layouts/main.gsp 0.7 kB
- mapper2.0/ivy.xml 2 kB
- mapper2.0/ivysettings.xml 0.8 kB
- mapper2.0/mapper-test.launch 0.8 kB
- mapper2.0/mapper.launch 2 kB
- mapper2.0/mapper.tmproj 2 kB
Issue Links
| This issue relates to: | ||||
| GRAILS-5952 | Grails filter is not executed when requesting (/index.gsp) |
|
|
|
| This issue is related to: | ||||
| GRAILS-5609 | before Interceptor not triggered for filter with global scope |
|
|
|
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
Erik,
In your original note you ask for a workaround. You could create a filter with a uri attribute like this:
class ExampleFilters {
def filters = {
sampleFilter(uri:'/') {
before = {
println 'hello'
}
}
}
}
class ExampleFilters {
def filters = {
sampleFilter(uri:'/') {
before = {
println 'hello'
}
}
}
}
Yes, although the workaround is not always possible. I realized that in my case it was not possible, mainly due to the fact that uri does not seem to support the regular expression syntax, and I have a relatively complex URL setup to support locales in the URL.
Ah, thanks, I'll try that out! I think it will work in my case since the problem I have is quite simple (retrieve some data on every call to /).
Another thing to note... If you add a url mapping which maps '/' to a controller action, your filters should work.
Jean-Noël,
I think the uri pattern does currently support ant style paths like '/*' and '/demo/'. Does that help with your situation?
Part of this issue is related to GRAILS-5609 which relates to filters not executing for default controller actions.
Hi,
I am not really sure what you meant with ant style paths like '/*' and '/demo/' since again the double star messed up the formatting. I think in my case it would not help (I need to catch all URIs of the form /{localeCode}/demo/** but localeCode is optional so it can be just demo/**
By the way please reopen this bug. I looked at your fix but this will only fix the OP problem eg when accessing the root of the app. As I mentionned the problem is much wider:
any URL which will result in not having an actionName will cause problems. For instance /demo/ if you have DemoController and def defaultAction = main. This wont be catch by a filter.
Please reopen. I'm seeing this in 1.2.1 too.
In my environment a filter for "/**" does not execute on a direct call to any /foo.gsp page, however it does execute on a call to a controller.
Tim,
I don't think this issue should be re-opened. I do think that the original issue has been resolved. The mapper2 application that the original poster attached does work with 1.2.1. I think the defaultAction thing that Jean mentions is resolved.
You may be seeing a different issue related to filters. If you want to create a simple demonstrative app and attach it to a new issue, we can investigate that. If you do that, feel free to link that issue as related to this one. Thanks for your help.
Jean-Noël,
I think that the defaultAction issue was resolved as part of GRAILS-5609.
Jeff,
Please see a new JIRA filed here: http://jira.codehaus.org/browse/GRAILS-5952
I will be the first to admit that this may be due to user error.
Once again, a thousand thanks for your help with this issue and others.
I can confirm this. This does not happen only in the root but in any URL where there is no action (so for a controller that has a defaultAction that triggers too).
Any filter with controller: "foo" and action: "*" in the rule will exhibit this.
It also does not work with any kind of regexp, even ".*"
This is IMHO a serious regression from and cause troubles for people upgrading (the new regexp syntax for filters is cool though
I suspect the bug comes from the fact that there is a test on actionName which is null or empty on this case.
Workaround: I got it working by switching to uri: /foo/**" in my case.