A friend told me a first error on

        ApplicationContext context = new 
ClassPathXmlApplicationContext("beans.xml");

scope request in only valid in a container. A ClassPathXmlApplicationContext is 
not able to handle a such scope.

-------- Message original --------
Sujet: Cxf spring and bean defined with "request" scope level.
De : Médérick Thebault <[email protected]>
Pour : [email protected]
Date : 15/09/2010 14:34

Good morning,

I was thinking my problem is related to CXF and Spring 
integration/configuration, but after some tries, I am a bit puzzled.

Here is the deal : In a webservice, I would like to get a bean defined in some 
beans.xml file as it is defined in Spring
and which is scope is "request".

<beans xmlns="http://www.springframework.org/schema/beans";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:aop="http://www.springframework.org/schema/aop";
xmlns:tx="http://www.springframework.org/schema/tx";
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd";>

<bean id="test" class="pricing.beans.Ancestor" scope="request">
<aop:scoped-proxy/>
</bean>
</beans>


Environment :
Web service with cxf 2.2.10 with spring conf.


Reading Spring documentation @ 
http://static.springsource.org/spring/docs/2.0.x/reference/beans.html shows :

_The other scopes, namely request, session, and global session are for use only 
in web-based applications (and can be
used irrespective of which particular web application framework you are using, 
if indeed any). In the interest of
keeping related concepts together in one place in the reference documentation, 
these scopes are described here.

[Note] Note :
The scopes that are described in the following paragraphs are only available if 
you are using a web-aware Spring
ApplicationContext implementation (such as XmlWebApplicationContext). If you 
try using these next scopes with regular
Spring IoC containers such as the XmlBeanFactory or 
ClassPathXmlApplicationContext, you will get an
IllegalStateException complaining about an unknown bean scope._

When trying to get a bean, I get the error mentioned, ie "No Scope registered for 
scope 'request'".

ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); 
//No exception here, beans.xml found.
Ancestor anc = (Ancestor) context.getBean("test"); // Exception cast here with
java.lang.IllegalStateException: No Scope registered for scope 'request' error 
message

That means I can not use this? Is there another way to achieve this, I mean 
getting a new Bean provided by CXF/Spring
for each HttpRequest?

Thanx for your help,

MT


<table>
<div style="width:60%;">
<hr>
</div>
<p style="font-size:10px; font-family:Verdana;line-height:10px;color:grey;">
<b>Bretagne Angleterre Irlande (Groupe Brittany Ferries - Serestel)</b><BR><BR>
Siège social : Port du Bloscon BP 72 29688 Roscoff cedex France - Tél + 33 2 98 29 28 
00 - Fax + 33 2 98 29 27 00<BR>
Société Anonyme à directoire et conseil de surveillance au capital de 22.831.056 
&euro;<BR>
RCS Brest 927 250 217 - Code APE 5010Z - Registre des Opérateurs de Voyages et de Séjours 
N&deg; IMO29100011<BR><BR>

Ce message et toutes les pièces jointes peuvent contenir des informations 
confidentielles à l'intention exclusive de ses
destinataires.<BR> Si vous le recevez par erreur, merci de bien vouloir nous en 
informer, et le supprimer.<BR>
This message and any attachments may contain confidential information for the 
intended recipient only.<BR> If you have
received it in error, please contact us, and delete it.<BR>
</p>
<div style="width:60%;">
<hr>
</div>
</table>


<table>
<div style="width:60%;">
<hr>
</div>
<p style="font-size:10px; font-family:Verdana;line-height:10px;color:grey;">
<b>Bretagne Angleterre Irlande (Groupe Brittany Ferries - Serestel)</b><BR><BR>
Siège social : Port du Bloscon BP 72 29688 Roscoff cedex France - Tél + 33 2 98 29 28 
00 - Fax + 33 2 98 29 27 00<BR>
Société Anonyme à directoire et conseil de surveillance au capital de 22.831.056 
&euro;<BR>
RCS Brest 927 250 217 - Code APE 5010Z - Registre des Opérateurs de Voyages et de Séjours  
N&deg; IMO29100011<BR><BR>

Ce message et toutes les pièces jointes peuvent contenir des informations confidentielles à l'intention exclusive de ses destinataires.<BR> Si vous le recevez par erreur, merci de bien vouloir nous en informer, et le supprimer.<BR> This message and any attachments may contain confidential information for the intended recipient only.<BR> If you have received it in error, please contact us, and delete it.<BR>
</p>
<div style="width:60%;">
<hr>
</div>
</table>

Reply via email to