You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Relph <re...@gmail.com> on 2008/01/04 21:50:24 UTC

struts2 spring plugin

I have read through the spring plugin wiki page
http://struts.apache.org/2.0.11/docs/spring-plugin.html for struts2.

I want my actions to be completely managed by spring, so i am declaring them
in applicationContext.xml.


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd

http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd

http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:util="http://www.springframework.org/schema/util">



<bean id="com.cerner.healthe.struts2.action.AccountResendAction"

      class="com.cerner.healthe.struts2.action.AccountResendAction"
singleton="false">

      <property name="userService"

                ref="com.cerner.healthe.struts2.service.UserService" />

      <property name="provisioningService"

                ref="com.cerner.healthe.struts2.service.ProvisioningService" />

</bean>



...

</beans>


However, when starting my application, spring throws an error:

*

org.xml.sax.SAXParseException*: cvc-complex-type.3.2.2: Attribute
'singleton' is not allowed to appear in element 'bean'.

I have also found an older version of the wiki page
http://cwiki.apache.org/WW/spring.html that gives an explanation of the
'singleton' attribute:

The singleton attribute is set to false, meaning that Spring will create a
new Action class upon each request, as Struts 1 would do.

Is this attribute no longer necessary?

Re: struts2 spring plugin

Posted by GF <ga...@gmail.com>.
Yes, on Spring 2 it is :

scope="prototype"


On Jan 7, 2008 8:41 AM, Joachim Ansorg <ja...@ksi.gr> wrote:
> Brian,
> I guess you are using Spring 2.x.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts2 spring plugin

Posted by Joachim Ansorg <ja...@ksi.gr>.
Brian,
I guess you are using Spring 2.x.

I think you have to use scope="prototype" (or scope="session" if you 
need it) instead of singleton="false".

Joachim
> I have read through the spring plugin wiki page
> http://struts.apache.org/2.0.11/docs/spring-plugin.html for struts2.
>
> I want my actions to be completely managed by spring, so i am declaring them
> in applicationContext.xml.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>
> http://www.springframework.org/schema/util
> http://www.springframework.org/schema/util/spring-util-2.0.xsd
>
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
>
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
>
> xmlns:aop="http://www.springframework.org/schema/aop"
>
> xmlns:tx="http://www.springframework.org/schema/tx"
>
> xmlns:util="http://www.springframework.org/schema/util">
>
>
>
> <bean id="com.cerner.healthe.struts2.action.AccountResendAction"
>
>       class="com.cerner.healthe.struts2.action.AccountResendAction"
> singleton="false">
>
>       <property name="userService"
>
>                 ref="com.cerner.healthe.struts2.service.UserService" />
>
>       <property name="provisioningService"
>
>                 ref="com.cerner.healthe.struts2.service.ProvisioningService" />
>
> </bean>
>
>
>
> ...
>
> </beans>
>
>
> However, when starting my application, spring throws an error:
>
> *
>
> org.xml.sax.SAXParseException*: cvc-complex-type.3.2.2: Attribute
> 'singleton' is not allowed to appear in element 'bean'.
>
> I have also found an older version of the wiki page
> http://cwiki.apache.org/WW/spring.html that gives an explanation of the
> 'singleton' attribute:
>
> The singleton attribute is set to false, meaning that Spring will create a
> new Action class upon each request, as Struts 1 would do.
>
> Is this attribute no longer necessary?
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts2 spring plugin

Posted by Dave Newton <ne...@yahoo.com>.
--- Brian Relph <re...@gmail.com> wrote:
> I want my actions to be completely managed by spring, so i am declaring
> them in applicationContext.xml.

Just FYI, you don't need to do that if you use Spring as the default object
factory (is that the default? I don't remember.)

> Is this ["singleton"] attribute no longer necessary?

IIRC Spring 2 doesn't have that attribute, and the error message kind of
verifies that, leading me to believe it wouldn't be necessary. Or possible.
Check out the "scope" attribute.

That said, S2 isn't designed to be used with singleton actions, so I don't
know what would happen.

d.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org