2011-06-24 3 views
3

SWF 2.2.1、Primefaces 2.2.1、JSF 2、Spring Security 3、Spring 3.1.0M1I、EhCache、AspectJ、Castor 。名前付きBeanの作成中にエラーが発生しました:スコープ 'request'が現在のスレッドで有効ではありません

私は、私は春のWebflowを使用し

<h:panelGrid> 
    <h:selectOneRadio id="#{msg.srchType}" value="#{acordRequest.insuranceSvcRq.com_csc_ClientSearchRq.com_csc_SearchInfo.com_csc_SearchCriteria.com_csc_ClientSearch.com_csc_SearchNameByType}"> 
     <f:selectItem itemLabel="#{msg.exact}" itemValue="E" id="#{msg.exact}" /> 
    <f:selectItem itemLabel="#{msg.phonetic}" itemValue="S" id="#{msg.phonetic}" /> 
    <f:selectItem itemLabel="#{msg.truncated}" itemValue="P" id="#{msg.truncated}" /> 
     </h:selectOneRadio> 
</h:panelGrid> 

のようなパラメータを構築していた場所から検索ページを持っている

<bean id="oXMapper" class="com.abc.xyz.util.OXMapper"> 
    <property name="unmarshaller" ref="unmarshaller" /> 
    <property name="marshaller" ref="marshaller" /> 
    <property name="acordRequest" ref="acordRequest" /> 
    <property name="acordResponse" ref="acordResponse" /> 
</bean> 

<bean id="unmarshaller" class="org.springframework.oxm.castor.CastorMarshaller"> 
    <property name="mappingLocation" 
     value="classpath:/templates/mapping/ACORD_Response_Mapping.xml" /> 
</bean> 

<bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller"> 
    <property name="mappingLocation" 
     value="classpath:/templates/mapping/ACORD_Request_Mapping.xml" /> 
</bean> 

<bean id="acordRequest" class="com.abc.xyz.cate.domain.ACORD"> 
    <property name="insuranceSvcRq" ref="insuranceSvcRq" /> 
    <property name="signonRq" ref="CltSearch_signonRq" /> 
</bean> 

のように私のアプリ-config.xmlにキャスターのための豆を定義していますOXMapper関数を呼び出して、ACORD(xmlを構築するのに使用されるような階層構造)オブジェクトを渡しています。このOXMapperクラスは、それぞれオブジェクトとXMLのマーシャリングとアンマーシャリングを行います。

今の問題は、私は検索ページで再度探していたときに、古い値が自動的にフィールド内に移入されます。

だから私は"スコープを"に変更しようとしました。私は次のエラーを取得する範囲を変更した後

<bean id="acordRequest" class="com.abc.xyz.cate.domain.ACORD" 
    scope="request"> 
    <property name="insuranceSvcRq" ref="insuranceSvcRq" /> 
    <property name="signonRq" ref="CltSearch_signonRq" /> 
</bean> 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oXMapper' defined in ServletContext resource [/WEB-INF/config/app-config.xml]: Cannot resolve reference to bean 'acordRequest' while setting bean property 'acordRequest'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'acordRequest': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: 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. 

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     /WEB-INF/config/web-application-config.xml 
    </param-value> 
</context-param> 
<error-page> 
    <error-code>500</error-code> 
    <location>/error.xhtml</location> 
</error-page> 
<context-param> 
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name> 
    <param-value>.xhtml</param-value> 
</context-param> 
<context-param> 
    <param-name>javax.faces.PROJECT_STAGE</param-name> 
    <param-value>Development</param-value> 
</context-param> 
<context-param> 
    <param-name>facelets.DEVELOPMENT</param-name> 
    <param-value>true</param-value> 
</context-param> 
<context-param> 
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> 
    <param-value>1</param-value> 
</context-param> 
<context-param> 
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name> 
    <param-value>/WEB-INF/springsecurity.taglib.xml</param-value> 
</context-param> 
<!-- Enables Spring Security --> 
<filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
    <dispatcher>REQUEST</dispatcher> 
    <dispatcher>INCLUDE</dispatcher> 
    <dispatcher>FORWARD</dispatcher> 
</filter-mapping> 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 
<listener> 
    <listener-class> 
     org.springframework.web.context.request.RequestContextListener</listener-class> 
</listener> 
<listener> 
    <listener-class> 
     org.springframework.security.web.session.HttpSessionEventPublisher</listener-class> 
</listener> 
<servlet> 
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value></param-value> 
    </init-param> 
    <load-on-startup>2</load-on-startup> 
</servlet> 
<servlet-mapping> 
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> 
    <url-pattern>/certs/*</url-pattern> 
</servlet-mapping> 
<servlet> 
    <servlet-name>Faces Servlet</servlet-name> 
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
    <servlet-name>Faces Servlet</servlet-name> 
    <url-pattern>*.faces</url-pattern> 
</servlet-mapping> 
<welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
</welcome-file-list> 

を次のように私のweb.xmlのが私の顔-config.xmlには何も持っていないですそのように

<faces-config xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" 
version="2.0"> 

<application> 
    <!-- <message-bundle>JsfMessageResources</message-bundle> --> 
</application> 
<!-- JSF 2.0 Version of this faces-config.xml file --> 

答えて

6

あなたはあなたのweb.xmlにRequestContextListenerを参照する必要があり、requestスコープを使用するためには、春のMVCを使用していない場合:

f you use a Servlet 2.4+ web container, with requests processed outside of Spring's DispatcherServlet (for example, when using JSF or Struts), you need to add the following javax.servlet.ServletRequestListener to the declarations in your web applications web.xml file:

<web-app> 
... 
<listener> 
    <listener-class> 
     org.springframework.web.context.request.RequestContextListener 
    </listener-class> 
</listener> 
... 
</web-app> 

引用をdocsから。

+1

replying.Iがyou.Stillで述べたように、私もweb.xml内RequestContextListener含めてみました、私は同じエラーを取得していますことを言及するのを忘れためabalogh感謝。 – C4CodeE4Exe

+0

:-(あなたはまた、それはあなたの問題を解決するが、新規の方があるときに、なぜ時代遅れのマイルストーンを使用する可能性は低い、春3.1M2にアップグレードしてみてください? – abalogh

+1

?あなたのweb.xmlファイルとのfaces-config.xmlのを投稿してくださいすることができ私はSpring 3.1M2のみを使用しています。更新されたものです。web.xml ad faces-config.xmlを投稿しました。ありがとうございました – C4CodeE4Exe

関連する問題