grails - java.lang.String cannot be cast to java.lang.Long in Spring Security ACL -


i use spring security acl plugin , have no acls set before. want access following service method:

@postfilter("haspermission(filterobject, read) or haspermission(filterobject, admin)") list<company> list(map params = [:]) {    return company.list(params) } 

i gave permission admin user company. when access above method works fine. problem occurs when stopped server , grails clean. when restart , access above method following error. strange because worked first time before grails clean without errors.

2015-08-08 14:57:02,509 [http-nio-8080-exec-5] error errors.grailsexceptionresolver  - classcastexception occurred when processing request: [get] /test2/home/list java.lang.string cannot cast java.lang.long. stacktrace follows: message: java.lang.string cannot cast java.lang.long     line | method ->>  305 | docall                 in org.grails.datastore.gorm.gormstaticapi$_withcriteria_closure11 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  |    302 | execute                in org.grails.datastore.mapping.core.datastoreutils |     37 | execute . . . . . . .  in org.grails.datastore.gorm.abstractdatastoreapi |    304 | withcriteria           in org.grails.datastore.gorm.gormstaticapi |    128 | lookupobjectidentities in grails.plugin.springsecurity.acl.jdbc.gormacllookupstrategy |    106 | docall                 in grails.plugin.springsecurity.acl.jdbc.gormacllookupstrategy$_readaclsbyid_closure1 |     78 | readaclsbyid . . . . . in grails.plugin.springsecurity.acl.jdbc.gormacllookupstrategy |    288 | readaclsbyid           in grails.plugin.springsecurity.acl.aclservice |    127 | list . . . . . . . . . in test2.homecontroller |    198 | dofilter               in grails.plugin.cache.web.filter.pagefragmentcachingfilter |     63 | dofilter . . . . . . . in grails.plugin.cache.web.filter.abstractfilter |     53 | dofilter               in grails.plugin.springsecurity.web.filter.grailsanonymousauthenticationfilter |     62 | dofilter . . . . . . . in grails.plugin.springsecurity.web.authentication.logout.mutablelogoutfilter |   1142 | runworker              in java.util.concurrent.threadpoolexecutor |    617 | run . . . . . . . . .  in java.util.concurrent.threadpoolexecutor$worker ^    745 | run                    in java.lang.thread error | 2015-08-08 14:57:03,030 [http-nio-8080-exec-6] error errors.grailsexceptionresolver  - classcastexception occurred when processing request: [get] /test2/home/list java.lang.string cannot cast java.lang.long. stacktrace follows: message: java.lang.string cannot cast java.lang.long     line | method ->>  305 | docall                 in org.grails.datastore.gorm.gormstaticapi$_withcriteria_closure11 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  |    302 | execute                in org.grails.datastore.mapping.core.datastoreutils |     37 | execute . . . . . . .  in org.grails.datastore.gorm.abstractdatastoreapi |    304 | withcriteria           in org.grails.datastore.gorm.gormstaticapi |    128 | lookupobjectidentities in grails.plugin.springsecurity.acl.jdbc.gormacllookupstrategy |    106 | docall                 in grails.plugin.springsecurity.acl.jdbc.gormacllookupstrategy$_readaclsbyid_closure1 |     78 | readaclsbyid . . . . . in grails.plugin.springsecurity.acl.jdbc.gormacllookupstrategy |    288 | readaclsbyid           in grails.plugin.springsecurity.acl.aclservice |    127 | list . . . . . . . . . in test2.homecontroller |    198 | dofilter               in grails.plugin.cache.web.filter.pagefragmentcachingfilter |     63 | dofilter . . . . . . . in grails.plugin.cache.web.filter.abstractfilter |     53 | dofilter               in grails.plugin.springsecurity.web.filter.grailsanonymousauthenticationfilter |     62 | dofilter . . . . . . . in grails.plugin.springsecurity.web.authentication.logout.mutablelogoutfilter |   1142 | runworker              in java.util.concurrent.threadpoolexecutor |    617 | run . . . . . . . . .  in java.util.concurrent.threadpoolexecutor$worker ^    745 | run                    in java.lang.thread 

i created demo project here: https://github.com/confile/spring-security-acl-bug

reproduce it:

edit: found when shut down mysql server , restart error gone. might belong caching issues here.

is there way catch error, e.g., in case no acls have been set before?

note: question still unanswered.

the issue seems related way aclsid overrides 1 in plugin.

you see java.lang.string cannot cast java.lang.long issue when plugins class won somehow.

there easy fix in general should running grails package after grails clean need make sure on ci server run package step before build war.

i have seen same issue since use uuids , had make aclsid class has string sid well. i've had no issues in production or locally once started correctly run package step.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -