@Resource annotation not used with beans defined by id
------------------------------------------------------
Key: WW-2336
URL: https://issues.apache.org/struts/browse/WW-2336
Project: Struts 2
Issue Type: Bug
Components: Plugin - Spring
Affects Versions: 2.0.11
Environment: spring 2.5, tomcat 6, java se 1.5, eclipse 3.3.0
Reporter: Sébastien Derivaux
Priority: Minor
There seems to be a problem with the spring interaction.
Consider the following scenario :
A action class using the @Resource annotation :
public class ListValuableAction {
@Resource
private StockManager stockManager;
They are mapped in the applicationContext.xml as beans :
<bean id="listValuableAction" scope="prototype"
class="gestion.view.actions.ListValuableAction"/>
<bean id="stockManager" class="capitalism.dao.StockManager"/>
In the struts.xml I have:
<action name="*" class="capitalism.view.actions.{1}Action" >
<result>/WEB-INF/views/{1}.jsp</result>
</action>
<action name="toto" class="listValuableAction" >
<result>/WEB-INF/views/ListValuable.jsp</result>
</action>
The first action works fine, the stockManager bean is set in the
ListValuableAction instance.
The second does not work. The stockManager bean is NOT set in the
ListValuableAction instance.
I try to play with scope="prototype", removing it. Does the same.
My unit tests complete fine using the bean listValuableAction, the stockManager
field is always set, so i'm quite sure is not a problem with Spring.
If I inject in the applicationContext.xml :
<bean id="listValuableAction" scope="prototype"
class="capitalism.view.actions.ListValuableAction">
<property name="stockManager" ref="stockManager"/>
</bean>
it works.
In conclusion the problem arise only when using a bean declared by id which use
the @Resource annotation.
Using @Resource in a bean declared by class name works.
Using a bean declared by id which injections are in the applicationContext.xml
works.
Hope it helps.
PS : Sorry if my English is a little poor.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.