Details
-
Type:
Bug
-
Status:
Reopened
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0 final
-
Fix Version/s: 2.3-M2
-
Component/s: Controllers, Project infrastructure
-
Environment:HideOS X Lion, 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)ShowOS X Lion, 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64 java version "1.6.0_29" Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527) Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
Description
I've created grails-app/conf/MyFilters.groovy
class MyFilters {
def filters = {
all(controller: "*", action: "*") {
before = {
log.info "Filtering $controllerName $actionName"
}
}
}
}
I've also configured logging to file "./grails.log". When I ran app as grails run-app - the message above is logged fine, if using grails run-war - message doesn't get logged.
Attached sample app.
-
Hide
- filter-test.zip
- 01/Feb/12 3:52 AM
- 114 kB
- Vladimir Grichina
-
- application.properties 0.1 kB
- grails-app/.../ApplicationResources.groovy 0.1 kB
- grails-app/conf/BootStrap.groovy 0.1 kB
- grails-app/conf/BuildConfig.groovy 2 kB
- grails-app/conf/Config.groovy 4 kB
- grails-app/conf/DataSource.groovy 1 kB
- grails-app/conf/MyFilters.groovy 0.2 kB
- grails-app/conf/spring/resources.groovy 0.0 kB
- grails-app/conf/UrlMappings.groovy 0.2 kB
- grails-app/i18n/messages.properties 3 kB
- grails-app/.../messages_cs_CZ.properties 3 kB
- grails-app/i18n/messages_da.properties 3 kB
- grails-app/i18n/messages_de.properties 4 kB
- grails-app/i18n/messages_es.properties 3 kB
- grails-app/i18n/messages_fr.properties 2 kB
- grails-app/i18n/messages_it.properties 2 kB
- grails-app/i18n/messages_ja.properties 4 kB
- grails-app/i18n/messages_nl.properties 3 kB
- grails-app/.../messages_pt_BR.properties 3 kB
- grails-app/.../messages_pt_PT.properties 3 kB
- grails-app/i18n/messages_ru.properties 4 kB
- grails-app/i18n/messages_sv.properties 3 kB
- grails-app/i18n/messages_th.properties 6 kB
- grails-app/.../messages_zh_CN.properties 2 kB
- grails-app/views/error.gsp 0.3 kB
- grails-app/views/index.gsp 3 kB
- grails-app/views/layouts/main.gsp 2 kB
- web-app/css/errors.css 2 kB
- web-app/css/main.css 11 kB
- web-app/css/mobile.css 1 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
Actually – my mistake, still exist in latest Grails version ![]()
I have the same issue
Filters working fine when running the application with run-app
Filters stop working when app is deployed to heroku or running the app with run-war
I can't replicate in either 2.0.0 or the latest code. Try adding println statements in addition to the logging statements to see whether the filters are firing or if it's just a Log4j issue.
Hi Burt did you tried with a grails prod run-war or grails run-war?
I'm only experiencing the issue when running using grails prod run-war
I also used print statements in addition to the log statement. It seems the filter is not firing
I have a similar issue. However, the test application does actually work for me.
The thing that DOESN'T work is putting NNNFilters.groovy inside a package.
When you put Filters.groovy into a package inside grails-app/conf OR simply specify package com.mypackage in the file header, the filter stops working.
A filter in com.mypackage package should be put in grails-app/conf/com/mypackage directory . This might explain why it works in run-app mode but not in run-war / war deployment.
I am using grails 2.0.4
The filters works fine.
I tried both conf/AppOtherFilters (no package) and conf/htmc/AppFilters (package htmc).
Initially it didn't work for me. And then I found my problem. The problem was that I renamed the file name from HtmcFilter.groovy to AppFilter.groovy but forgot to rename the class name inside the source file. Strangely enough grails
didn't give me any compilation error and it actually run OK in dev mode.
In any case, renaming the class inside the source file to match the name of the file resolved the issue.
So, double check to make sure that your class name matches your file name, and also the package name if applicable if any.
Sorry, the line 'I tried both conf/AppOtherFilters (no package) and conf/htmc/AppFilters (package htmc).'
should be 'I tried both conf/AppOtherFilters.groovy (no package) and conf/htmc/AppFilters.groovy (package htmc).'
I wrote a small tutorial on how to get filters to work using grails version 2.0.4 to display the number of times the grails application (site) and a particular page on the site is visited. Here is the link to the tutorial Visiting count statistics using grails filters.
Looks like it is already fixed in latest Grails on GitHub.