2011-11-04 40 views
12


我剛剛創建了一個新的Grails應用程序內,
一切都很好,直到我決定
安裝後Spring Security Core。
Grails的錯誤:沒有線程綁定請求中找到:你是指請求屬性......安裝Spring Security的核心

安裝Spring Security的核心
做一個S2-快速入門並創下
的Grails運行的應用程序後,它產生的
以下錯誤:

URI 
/test1/ 
Class 
java.lang.IllegalStateException 
Message 
No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. 

有人知道如何解決這一問題?
我真的很感激,如果你幫到
。我曾嘗試在其他網站上尋找
的答案,但是
我無法解決它。 :)
順便說一句,我使用:
Spring Security的核心1.2.4
Grails的2.0.0.RC1

+0

什麼控制器並在URI/TEST1 /打?它採取了什麼行動?您可以從控制器發佈任何代碼都會有所幫助,因爲它可能是控制器內的某些內容或不在事務性會話內的服務。 – Todd

+0

你好, 我只是腳手架所有的控制器,除了由Spring安全核心本身產生的。/test1 /是我的應用程序的名稱。 :) –

+0

我剛剛嘗試創建一個項目,添加一個域類,在該域中生成所有內容,安裝spring-security-core,運行s2-quickstart,並且它工作正常。你有沒有試過grails清潔? – Todd

回答

7

這可以,如果你使用Spring Security的核心較舊版本的發生。從grails 1.3.7(和spring security 1.1.3)升級到grails 2.0.0時,我遇到了這個問題。此修復程序是在application.properties更改爲春季安全內核1.2:http://jira.grails.org/browse/GPSPRINGSECURITYCORE-98

plugins.spring-security-core=1.2 

更多信息由황현정建議。

+0

非常好,像魅力一樣工作,但是grails發出的's2-quickstart'消息告訴我要運行該命令? – raffian

16

如果你使用Maven的時候,確保你有這對你的pom.xml:

<dependency> 
    <groupId>org.grails.plugins</groupId> 
    <artifactId>webxml</artifactId> 
    <version>1.4.1</version> 
    <scope>runtime</scope> 
    <type>zip</type> 
</dependency> 

和BuildConfig,常規:

runtime ":webxml:1.4.1" 

上解決了這個問題,我使用Grails 2.2.0。

+2

這個修復了我在Grails 2.2.3,spring-security-core 1.2.7.3,謝謝! – Keeth

+0

修改BuildConfig.groovy對我無效,但在application.properties中添加了「plugins.webxml = 1.4.1」解決了它。 (我正在使用ggts) – bebbo

1

嘗試在web.xml文件中註冊RequestContextListener偵聽器。

文件:web.xml中

<web-app> 
    ... 
    <listener> 
    <listener-class> 
     org.springframework.web.context.request.RequestContextListener 
    </listener-class> 
    </listener> 
</web-app> 
相關問題