Grails spring security core,spring security rest IllegalStateException

标签 grails spring-security spring-security-rest

我在尝试对我的服务器进行 http(get 或 post)调用以获取某些数据时收到此 IllegalStateException。我正在构建这个使用其他应用程序方法的应用程序。客户端命名为 app1,服务器命名为 app2。
app2 有 spring security core,spring security rest 插件。当我执行 api/login 时, token 被呈现回 app1。可以假设插件已经处理了 session 吗?还是我应该自己处理?
文档对我来说很难理解,但我认为这并不清楚。我正在使用以下版本的插件

        compile ':spring-security-core:2.0-RC3'
        compile ':spring-security-ldap:2.0.0'
        compile ':spring-security-rest:1.4.0', {
            excludes: 'spring-security-core'
        }
        compile ':cors:1.1.6'

我将为一个 get 调用粘贴错误,我在 app1 中执行的每个调用都会引发此错误。如果您需要其他东西来帮助您解决我的问题,请告诉我。
     Error |
2018-12-07 10:53:54,921 [http-bio-8080-exec-2] ERROR errors.GrailsExceptionResol
ver  - IllegalStateException occurred when processing request: [GET] /TERA/repor
te/getInstancias
Cannot create a session after the response has been committed. Stacktrace follow
s:
Message: Cannot create a session after the response has been committed
    Line | Method
->>   18 | doCall             in SecurityFilters$_closure1_closure2_closure3
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|     99 | processFilterChain in com.odobo.grails.plugin.springsecurity.rest.Res
tTokenValidationFilter
|     66 | doFilter . . . . . in     ''
|     53 | doFilter           in grails.plugin.springsecurity.web.filter.GrailsA
nonymousAuthenticationFilter
|    108 | doFilter . . . . . in com.odobo.grails.plugin.springsecurity.rest.Res
tAuthenticationFilter
|     62 | doFilter           in grails.plugin.springsecurity.web.authentication
.logout.MutableLogoutFilter
|     63 | doFilter . . . . . in com.odobo.grails.plugin.springsecurity.rest.Res
tLogoutFilter
|     59 | doFilter           in grails.plugin.springsecurity.web.SecurityReques
tHolderFilter
|     82 | doFilter . . . . . in com.brandseye.cors.CorsFilter
|   1110 | runWorker          in java.util.concurrent.ThreadPoolExecutor
|    603 | run . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run                in java.lang.Thread

提前致谢!

最佳答案

我发现服务的范围可能会导致此错误,我的范围是原型(prototype),这就是导致我的错误的原因。我已将其更改为 session ,并且效果很好!
问题是一些必须运行的作业没有运行。所以我将范围重新设置为原型(prototype)。

关于Grails spring security core,spring security rest IllegalStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53671214/

相关文章:

rest - 禁用RestAuthenticationFilter-Grails Spring Security Rest插件

spring-mvc - 使用 Spring MVC 测试框架测试安全的 REST 端点

grails - Spring Security ACL和Postgres

grails - grails g:每个标记在 View 中均未显示任何内容

validation - 命令类中缺少validate()方法

spring-boot - 无法解析 Spring Boot 版本 2.0.6 中的 WebSecurityConfigurerAdapter 类

grails - 如何在GRAILS JWT中发送其他参数

tomcat - Spring 安全上下文路径解析器

java - Spring Security getPrincipal() 方法返回 anonymousUser

java - Spring Boot 2 拦截器对每个请求解析 `/login'