You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris <cr...@gmx.us> on 2015/09/06 06:38:47 UTC
Re: RE: Spring Injection Strange behaviour - SOLVED!
Finally I found the root cause.
It seems I had some Spring jars of an earlier version in my Tomcat lib directory on my dev machine, since I have more than one version of tomcat on my system I was looking in the wrong instance of tomcat when I was trying identify the cause. Sometimes I am such an idiot.
Thanks
Chris
Sent: Sunday, September 06, 2015 at 3:32 AM
From: Chris <cr...@gmx.us>
To: "Dave Newton" <da...@gmail.com>, "Struts Users Mailing List" <us...@struts.apache.org>
Subject: RE: Spring Injection Strange behaviour
Hi Dave,
Thanks for your reply.
I tried setting the scope of the action bean to prototype (amoung 100 other things) but it didn't change the behaviour. I'm using Struts2 with Sping plugin, jdk1.8.0_51.
If it wasn't calling the setter that would make more sense, but sine it is calling the setter that makes me beleive he autowiring is working, I just can't understand why its later being set to null. I thought it might be a scope issue but I don't know enough about struts to dig much deeper.
Thanks
Chris
-----Original Message-----
From: Dave Newton [mailto:davelnewton@gmail.com]
Sent: Saturday, September 5, 2015 11:27 PM
To: Struts Users Mailing List
Subject: Re: Spring Injection Strange behaviour
Not sure, but if nothing else the action should be set to `prototype` scope, as they're instantiated per-request.
Are you using the Struts 2 Spring plugin?
On Sat, Sep 5, 2015 at 8:47 AM, Chris <crispyoz@gmx.us[mailto:crispyoz@gmx.us]> wrote:
> I'm trying to use the Spring plugin to inject a dependency into my
> action at runtime. This is the first time I've tried this with Struts2
> so I may have missed something but I'm stumped because I can see the
> dependency is injected but then the object is later null when I need
> to use it. Here is my action class code:
>
> public class UserRegisterAction extends ActionSupport {
> private User user = new User();
>
---------------------------------------------------------------------
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: Spring Injection Strange behaviour - SOLVED!
Posted by Martin Gainty <mg...@hotmail.com>.
"Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth"....Arthur Conan Doyle
You had to eliminate the other Tomcats as the cause
"Genius is one percent inspiration and ninety-nine percent perspiration." - Thomas A. Edison
Then you set out the hardwork to find where the auto-wiring is happening
By Doyles definition you have "good investigative technique"
By Edisons definition you are a genius
Congratulations Chris!
Martin
______________________________________________
> From: crispyoz@gmx.us
> To: user@struts.apache.org
> CC: user@struts.apache.org
> Subject: Re: RE: Spring Injection Strange behaviour - SOLVED!
> Date: Sun, 6 Sep 2015 06:38:47 +0200
>
>
> Finally I found the root cause.
>
> It seems I had some Spring jars of an earlier version in my Tomcat lib directory on my dev machine, since I have more than one version of tomcat on my system I was looking in the wrong instance of tomcat when I was trying identify the cause. Sometimes I am such an idiot.
>
> Thanks
>
> Chris
>
>
> Sent: Sunday, September 06, 2015 at 3:32 AM
> From: Chris <cr...@gmx.us>
> To: "Dave Newton" <da...@gmail.com>, "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: RE: Spring Injection Strange behaviour
>
> Hi Dave,
>
> Thanks for your reply.
>
> I tried setting the scope of the action bean to prototype (amoung 100 other things) but it didn't change the behaviour. I'm using Struts2 with Sping plugin, jdk1.8.0_51.
>
> If it wasn't calling the setter that would make more sense, but sine it is calling the setter that makes me beleive he autowiring is working, I just can't understand why its later being set to null. I thought it might be a scope issue but I don't know enough about struts to dig much deeper.
>
> Thanks
>
> Chris
>
> -----Original Message-----
> From: Dave Newton [mailto:davelnewton@gmail.com]
> Sent: Saturday, September 5, 2015 11:27 PM
> To: Struts Users Mailing List
> Subject: Re: Spring Injection Strange behaviour
>
> Not sure, but if nothing else the action should be set to `prototype` scope, as they're instantiated per-request.
>
> Are you using the Struts 2 Spring plugin?
>
> On Sat, Sep 5, 2015 at 8:47 AM, Chris <crispyoz@gmx.us[mailto:crispyoz@gmx.us]> wrote:
>
> > I'm trying to use the Spring plugin to inject a dependency into my
> > action at runtime. This is the first time I've tried this with Struts2
> > so I may have missed something but I'm stumped because I can see the
> > dependency is injected but then the object is later null when I need
> > to use it. Here is my action class code:
> >
> > public class UserRegisterAction extends ActionSupport {
> > private User user = new User();
> >
>
> ---------------------------------------------------------------------
> 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
>