5608057 / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

JavaMelody does not work with Grails Filters #334

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Reproduce:

1. Grails 2.2.3, Java 1.6.0_51 (mac), JavaMelody 1.46 (latest, I believe)

$ grails create-app monitor-test
$ cd monitor-test
$ vi grails-app/conf/BuildConfig.groovy  # Inside plugins{  ... } add
        build ":tomcat:$grailsVersion"     (probably already there)
        compile ":grails-melody:1.46"
$ vi grails-app/conf/SecurityFilters.groovy
    class SecurityFilters {
        def filters = {
            helloController(controller:'hello', action:'*') {
                before = {
                    println "${controllerName} ${actionName}"
                }
            }
            monitoringController(controller:'monitoring', action:'*') {
                before = {
                    println "${controllerName} ${actionName}"
                }
            }
        }
    }
$ grails create-controller hello
$ echo "hello" > grails-app/views/hello/index.gsp

2. In your browser go to http://localhost:8080/monitor-test/hello/index
3. The console will output "hello index" as expected (from the filter).
4. In your browser go to http://localhost:8080/monitor-test/monitoring
5. The javamelody graphs and stats will be shown, but the filter code is never 
executed.
6. You can edit the filter so the first filter handles controller '*' and 
remove the second filter (for monitoring) but it still never actives when you 
hit the monitoring page.

This means I cannot really use JavaMelody in my app, sadly, until I figure out 
how to make it filterable.

Additionally, 

Original issue reported on code.google.com by kdo...@gmail.com on 19 Aug 2013 at 8:40

GoogleCodeExporter commented 8 years ago
First, if you use spring security, then adding just the following in 
Config.groovy is supposed to work:
grails.plugins.springsecurity.interceptUrlMap = [
                '/monitoring/**': ['ROLE_ADMIN'],
]

Otherwise, you should note that the "monitoring" url of melody is not a 
controller, it's a filter. So I don't think that the following would work: 
"monitoringController(controller:'monitoring', action:'*')".

Original comment by evernat@free.fr on 31 Aug 2013 at 9:27

GoogleCodeExporter commented 8 years ago
And I don't know how to make it work in SecurityFilters.groovy

By the way, the issues in the grails plugin are now at:
https://github.com/evernat/grails-melody-plugin/issues
So this issue is now moved to:
https://github.com/evernat/grails-melody-plugin/issues/8

Original comment by evernat@free.fr on 31 Aug 2013 at 10:38