gpt4 book ai didi

grails - Spring Security ACL中无法将java.lang.String强制转换为java.lang.Long

转载 作者:行者123 更新时间:2023-12-02 15:23:38 25 4
gpt4 key购买 nike

我使用Spring Security ACL plugin且之前未设置ACL。我想访问以下服务方法:

@PostFilter("hasPermission(filterObject, read) or hasPermission(filterObject, admin)")
List<Company> list(Map params = [:]) {
return Company.list(params)
}

我已授予公司管理员用户的权限。当我访问上述方法时,一切正常。当我停止服务器并执行 grails clean时,会发生问题。当我重新启动并访问上述方法时,出现以下错误。这是很奇怪的,因为它是在grails干净无误之前第一次工作的。
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 be cast to java.lang.Long. Stacktrace follows:
Message: java.lang.String cannot be cast to 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 be cast to java.lang.Long. Stacktrace follows:
Message: java.lang.String cannot be cast to 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

我在这里创建了一个演示项目: https://github.com/confile/Spring-Security-ACL-Bug

重现它:
  • 创建一个mysql数据库名称:test
  • grails dbm-update
  • grails运行应用程序
  • http://localhost:8080/test2/home/list
  • 用户登录:admin密码:admin
  • http://localhost:8080/test2/home/createCompany1
  • http://localhost:8080/test2/home/addPerm
  • http://localhost:8080/test2/home/createCompany2
  • http://localhost:8080/test2/home/list
  • 停止服务器
  • grails清洁
  • grails运行应用程序
  • http://localhost:8080/test2/home/list

  • 编辑:我发现当我关闭我的mysql服务器并重新启动它时,错误消失了。它可能属于此处的某些缓存问题。

    是否可以捕获此错误,例如,如果以前未设置ACL,该方法是否可以捕获?

    注意:这个问题仍然没有答案。

    最佳答案

    这个问题似乎与AclSid覆盖插件中的问题有关。

    当插件类以某种方式获胜时,您将看到java.lang.String cannot be cast to java.lang.Long问题。

    通常有一个简单的解决方法,您在执行grails package之后始终应该运行grails clean,并且还需要确保在ci服务器上,在建立 war 之前运行package步骤。

    由于我们使用UUID,并且不得不使AclSid类也具有sid字符串,因此我也遇到了同样的问题。一旦我们开始正确运行打包步骤,我就不会在生产环境或本地出现任何问题。

    关于grails - Spring Security ACL中无法将java.lang.String强制转换为java.lang.Long,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31597897/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com