You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Micael Carreira <mc...@itclinical.com> on 2019/01/02 15:07:11 UTC

Re: Context parameters not being ignored?

Sorry for the delay in replying, I was on holidays. By the way, have a 
happy new year :)

Here is the stack trace of both injections:
https://pastebin.com/6wMpWK8a

Cheers,
Micael

On 22/12/18 08:19, Yasser Zamani wrote:
> Hi Micael,
>
> I think putting a breakpoint on OtherAction.setFooService and probing the full stack trace when the execution hits it for second time would help to reveal what and who's the villain of second injection :)
>
> Regards.
>
>> -----Original Message-----
>> From: Micael Carreira <mc...@itclinical.com>
>> Sent: Thursday, December 20, 2018 10:55 PM
>> To: user@struts.apache.org
>> Subject: Context parameters not being ignored?
>>
>> Hello,
>>
>> I'm using Struts2 with Spring. I have the following action:
>>
>>      SomeAction
>>        |- FooService
>>
>> But in my bean definition I don't have the FooService dependency because
>> SomeAction doesn't use it:
>>
>>      <bean id="someAction" class="SomeAction" scope="prototype" />
>>
>> (Putting it this way doesn't make much sense, the real configuration is more
>> complex than this, but this is the simplest example on how the problem can be
>> reproduced)
>>
>> Then my struts.xml redirects to a jsp result:
>>
>>      <action name="SomeAction*" method="{1}" class="someAction">
>>          <result>/jsp/some.jsp</result>
>>      </action>
>>
>>
>> And some.jsp calls other action:
>>
>>      <s:action name="OtherAction" var="other" executeResult="false"
>> ignoreContextParams="true"></s:action>
>>
>> But OtherAction actually needs FooService as a dependency, and its bean
>> definition reflects that:
>>
>>      <bean id="otherAction" class="OtherAction" scope="prototype">
>>          <property name="fooService" ref="fooService" />
>>      </bean>
>>
>> I noticed that when OtherAction gets instantiated through jsp parsing, it first gets
>> set with the correct fooService dependency.
>>
>> However, after that, fooService then gets set with null. So OtherAction won't be
>> able to correctly run.
>>
>> I already assessed that the second injection is the value that is present in
>> SomeAction.
>>
>> But I don't want this value injected. It shouldn't be injected if I'm running
>> OtherAction with ignoreContextParams="true", right?
>>
>> I have been all day around this problem, so any help would be much appreciated.
>>
>> Cheers,
>> Micael
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

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


RE: Context parameters not being ignored?

Posted by Yasser Zamani <ya...@apache.org>.
Hi Micael, Happy New Year :)

With a glance on stack traces, I saw the second isn't an injection but is a copy-paste operation from prior action to next action by ChainingInterceptor. i.e. it seems you have a cyclic chain result or a chain result between two actions that both have fooService. Please consider some analysis on your chain results then I think you may find some trifles to fix.

Thanks for using Struts!

Regards.

>-----Original Message-----
>From: Micael Carreira <mc...@itclinical.com>
>Sent: Wednesday, January 2, 2019 6:37 PM
>To: user@struts.apache.org
>Subject: Re: Context parameters not being ignored?
>
>Sorry for the delay in replying, I was on holidays. By the way, have a happy new
>year :)
>
>Here is the stack trace of both injections:
>https://pastebin.com/6wMpWK8a
>
>Cheers,
>Micael
>
>On 22/12/18 08:19, Yasser Zamani wrote:
>> Hi Micael,
>>
>> I think putting a breakpoint on OtherAction.setFooService and probing
>> the full stack trace when the execution hits it for second time would
>> help to reveal what and who's the villain of second injection :)
>>
>> Regards.
>>
>>> -----Original Message-----
>>> From: Micael Carreira <mc...@itclinical.com>
>>> Sent: Thursday, December 20, 2018 10:55 PM
>>> To: user@struts.apache.org
>>> Subject: Context parameters not being ignored?
>>>
>>> Hello,
>>>
>>> I'm using Struts2 with Spring. I have the following action:
>>>
>>>      SomeAction
>>>        |- FooService
>>>
>>> But in my bean definition I don't have the FooService dependency
>>> because SomeAction doesn't use it:
>>>
>>>      <bean id="someAction" class="SomeAction" scope="prototype" />
>>>
>>> (Putting it this way doesn't make much sense, the real configuration
>>> is more complex than this, but this is the simplest example on how
>>> the problem can be
>>> reproduced)
>>>
>>> Then my struts.xml redirects to a jsp result:
>>>
>>>      <action name="SomeAction*" method="{1}" class="someAction">
>>>          <result>/jsp/some.jsp</result>
>>>      </action>
>>>
>>>
>>> And some.jsp calls other action:
>>>
>>>      <s:action name="OtherAction" var="other" executeResult="false"
>>> ignoreContextParams="true"></s:action>
>>>
>>> But OtherAction actually needs FooService as a dependency, and its
>>> bean definition reflects that:
>>>
>>>      <bean id="otherAction" class="OtherAction" scope="prototype">
>>>          <property name="fooService" ref="fooService" />
>>>      </bean>
>>>
>>> I noticed that when OtherAction gets instantiated through jsp
>>> parsing, it first gets set with the correct fooService dependency.
>>>
>>> However, after that, fooService then gets set with null. So
>>> OtherAction won't be able to correctly run.
>>>
>>> I already assessed that the second injection is the value that is
>>> present in SomeAction.
>>>
>>> But I don't want this value injected. It shouldn't be injected if I'm
>>> running OtherAction with ignoreContextParams="true", right?
>>>
>>> I have been all day around this problem, so any help would be much
>appreciated.
>>>
>>> Cheers,
>>> Micael
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org