grails用户创建NPE

时间:2014-06-09 18:11:38

标签: spring grails spring-security grails-plugin

我在尝试将User保存到数据库时遇到异常,我正在使用: grails 2.4.0 弹簧安全核:2.0-RC3

这是我的示例代码:

class MyRegisterController {


    def creatingUser(){
        User user = new User()

        user.username = "sunny"
        user.password = "sunny123#"
        user.email = "myemail@dontexist.com"
        user.accountExpired = false
        user.save();

        println("saved...")
        render (text: "test")
    }
}

如果有人遇到类似问题,请告诉我。

2014-06-09 22:01:19,824 [http-bio-8080-exec-5] DEBUG hierarchicalroles.RoleHierarchyImpl  - getReachableGrantedAuthorities() - From the roles [ROLE_ANONYMOUS] one can reach [ROLE_ANONYMOUS] in zero or more steps.
2014-06-09 22:01:19,824 [http-bio-8080-exec-5] DEBUG intercept.FilterSecurityInterceptor  - Authorization successful
2014-06-09 22:01:19,824 [http-bio-8080-exec-5] DEBUG intercept.FilterSecurityInterceptor  - RunAsManager did not change Authentication object
2014-06-09 22:01:19,824 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /myRegister/creatingUser reached end of additional filter chain; proceeding with original chain
| Error 2014-06-09 22:01:20,029 [http-bio-8080-exec-5] ERROR errors.GrailsExceptionResolver  - NullPointerException occurred when processing request: [GET] /pm-api/myRegister/creatingUser
Stacktrace follows:
Message: null
   Line | Method
->>  23 | creatingUser in com.pm.MyRegisterController$$EOgiEc9Y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   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
|    49 | doFilter . . in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
|    82 | doFilter     in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
|   895 | runTask . .  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run          in     ''
^   695 | run . . . .  in java.lang.Thread
2014-06-09 22:01:21,518 [http-bio-8080-exec-5] DEBUG context.HttpSessionSecurityContextRepository  - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2014-06-09 22:01:21,520 [http-bio-8080-exec-5] DEBUG access.ExceptionTranslationFilter  - Chain processed normally
2014-06-09 22:01:21,520 [http-bio-8080-exec-5] DEBUG context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed
2014-06-09 22:01:21,535 [http-bio-8080-exec-8] DEBUG matcher.AntPathRequestMatcher  - Request '/assets/main.css' matched by universal pattern '/**'
2014-06-09 22:01:21,535 [http-bio-8080-exec-6] DEBUG matcher.AntPathRequestMatcher  - Request '/assets/application.css' matched by universal pattern '/**'
2014-06-09 22:01:21,536 [http-bio-8080-exec-8] DEBUG web.FilterChainProxy  - /assets/main.css?compile=false at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2014-06-09 22:01:21,535 [http-bio-8080-exec-2] DEBUG matcher.AntPathRequestMatcher  - Request '/assets/mobile.css' matched by universal pattern '/**'

1 个答案:

答案 0 :(得分:0)

好像我搞砸了grails安全核心,ui和其他插件。我创建了一个新项目,它就像一个魔术。

感谢大家的帮助。