could not initialize proxy - no Session, accessing the session object in the filters

chessmonster

New member
i'm a bit new on the groovy grails technology and i'm having a problem with this one

i looked at this could not initialize proxy - no Session but the application don't get stale too long

I am trying to access the session object on my SecurityFilter placed on the config subfolder. I just wanted to do a check for every request on the controllers to verify if a user has the rights to do such actions.
Code:
class SecurityFilters {
    def filters = {

    userFilterList(controller:"user", action:"list") {
        before = {
            if (!session.user.accountType.equals("Admin")) {
                redirect(uri: "/")
            }
        }
    }
    userFilterShow(controller:"user", action:"show") {
        before = {
            if (!session.user.accountType.equals("Admin")) {
                redirect(uri: "/")
            }
        }
    }
    userFilterEdit(controller:"user", action:"edit") {
        before = {
            if (!session.user.accountType.equals("Admin")) {
                redirect(uri: "/")
            }
        }
    }

    }
}
but I get this error
Code:
Message: could not initialize proxy - no Session
Line | Method
->>    6 | doCall    in SecurityFilters$_closure1_closure2_closure5
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    186 | doFilter  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter  in grails.plugin.cache.web.filter.AbstractFilter
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    636 | run       in java.lang.Thread
before I get to this point I placed the user object on the session object right after doing the login instructions but I am not sure what happened that the session object became not available
 

chessmonster

New member
I just did the per controller class interceptor. it did the job but not as elegant as with the use of filters :D


i'm a bit new on the groovy grails technology and i'm having a problem with this one

i looked at this could not initialize proxy - no Session but the application don't get stale too long

I am trying to access the session object on my SecurityFilter placed on the config subfolder. I just wanted to do a check for every request on the controllers to verify if a user has the rights to do such actions.
Code:
class SecurityFilters {
    def filters = {

    userFilterList(controller:"user", action:"list") {
        before = {
            if (!session.user.accountType.equals("Admin")) {
                redirect(uri: "/")
            }
        }
    }
    userFilterShow(controller:"user", action:"show") {
        before = {
            if (!session.user.accountType.equals("Admin")) {
                redirect(uri: "/")
            }
        }
    }
    userFilterEdit(controller:"user", action:"edit") {
        before = {
            if (!session.user.accountType.equals("Admin")) {
                redirect(uri: "/")
            }
        }
    }

    }
}
but I get this error
Code:
Message: could not initialize proxy - no Session
Line | Method
->>    6 | doCall    in SecurityFilters$_closure1_closure2_closure5
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    186 | doFilter  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter  in grails.plugin.cache.web.filter.AbstractFilter
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    636 | run       in java.lang.Thread
before I get to this point I placed the user object on the session object right after doing the login instructions but I am not sure what happened that the session object became not available
 
Top