我目前正在开发 Grails 应用程序,并将 Spring Security 框架与 Core 和 UI 插件一起使用。
几乎一切工作正常:用户创建、编辑、删除等。唯一的问题是 requestmap,它不能正常工作。当我调用 requestmap/create 时,出现以下错误:
URI /xxx/requestmap/create
Class java.lang.NullPointerException
Message Cannot get property 'clazz' on null object
Around line 81 of grails-app/controllers/grails/plugins/springsecurity/ui/AbstractS2UiController.groovy
78: }
79:
80: protected Class<?> lookupRequestmapClass() {
81: grailsApplication.getDomainClass(lookupRequestmapClassName()).clazz
82: }
83:}
我在我的 Config.groovy 中配置了 Spring Security,如下所示:
grails.plugins.springsecurity.userLookup.userDomainClassName = 'xxx.User'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'xxx.UserRole'
grails.plugins.springsecurity.authority.className = 'xxx.Role'
grails.plugins.springsecurity.requestMap.className = 'Requestmap'
grails.plugins.springsecurity.securityConfigType = grails.plugins.springsecurity.SecurityConfigType.Requestmap
我还在 BuildConfig.groovy 中使用了以下插件:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":resources:1.1.6"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.1"
compile ':cache:1.0.0'
// Spring Security Core
compile ":spring-security-core:1.2.7.3"
// Spring Security UI (+ Dependencies)
compile ":spring-security-ui:0.2"
compile ":mail:1.0"
runtime ":jquery:1.7.2"
compile ":jquery-ui:1.8.15"
compile ":famfamfam:1.0.1"
// Twitter Bootstrap
// exlude is workaround for svn issue with bootstrap and grails 2.1.x
compile (":twitter-bootstrap:2.0.2.25") { excludes 'svn' }
runtime ':fields:1.3'
}
出现requestmap搜索表单,但搜索时抛出异常:
URI /xxx/requestmap/requestmapSearch
Class org.hibernate.hql.ast.QuerySyntaxException
Message xxx.Requestmap is not mapped [SELECT COUNT(DISTINCT r) FROM xxx.Requestmap r WHERE 1=1 ]
Around line 46 of grails-app/controllers/grails/plugins/springsecurity/ui/RequestmapController.groovy
43: }
44: }
45:
46: int totalCount = lookupUserClass().executeQuery("SELECT COUNT(DISTINCT r) $hql", queryParams)[0]
47:
48: Integer max = params.int('max')
49: Integer offset = params.int('offset')
我现在正在处理这个错误一段时间,做了我在文档中找到的所有内容。这是与另一个插件结合时 Spring Security 中的错误还是这里发生了什么?如果没有请求图,Spring Security UI 插件对我来说毫无意义。我需要它来工作。