This definitely used to work in previous Struts versions (e.g. 2.0.7, 2.0.9, and 2.0.14) so I think this is a bug. In fact, this bug had occurred in previous 2.0.x versions but had been fixed (see http://jira.opensymphony.com/browse/XW-472). I submitted an XWork bug a couple weeks ago (http://jira.opensymphony.com/browse/XW-725), but so far there is no response.
In previous Struts versions, the object factory used to instantiate type converters was org.apache.struts2.spring.StrutsSpringObjectFactory, but in 2.1.6 it is com.opensymphony.xwork2.ObjectFactory instead. The implementation of http://jira.opensymphony.com/browse/XW-566 probably caused this because the object factory used to create type converters is now injected instead of statically set. In the reloadContainer method of com.opensymphony.xwork2.config.impl.DefaultConfiguration, ObjectFactory is used to create the bootstrap container which contains XWorkConverter. Therefore, an ObjectFactory instance gets injected into XWorkConverter which means that the type converters in xwork-conversion.properties cannot be Spring beans. This seems to be a major bug. Is anyone working on a fix? Griffith, Michael * wrote: > > Thanks for the suggestion. Maybe this should be considered as a future > feature enhancement. > > MG > > -----Original Message----- > From: Musachy Barroso [mailto:musa...@gmail.com] > Sent: Friday, February 06, 2009 9:12 AM > To: Struts Users Mailing List > Subject: Re: TypeConverter needs Spring Bean > > The converters are created by the internal IOC container, so the Spring > beans wont be injected. A "hack" I can think of is to add something like > this to the converter: > > @Inject(StrutsConstants.STRUTS_OBJECTFACTORY) > public void setObjectFactory(ObjectFactory factory) { > //save the factory for later > } > > that factory will be the Spring object factory, which you can use to > lookup the beans that you need. Not much of "inversion of control" but > it should work. > > musachy > > On Fri, Feb 6, 2009 at 9:59 AM, Griffith, Michael * > <michael.griff...@fda.hhs.gov> wrote: >> How can you tell? This is handed by the plug-in, right? From my >> struts.properties file: >> >> struts.objectFactory = spring >> struts.objectFactory.spring.autoWire = name >> struts.objectFactory.spring.useClassCache = true >> >> -----Original Message----- >> From: Musachy Barroso [mailto:musa...@gmail.com] >> Sent: Friday, February 06, 2009 8:54 AM >> To: Struts Users Mailing List >> Subject: Re: TypeConverter needs Spring Bean >> >> Are the converters created by the object factory? if not, then it will > >> not work. >> >> musachy >> >> On Fri, Feb 6, 2009 at 9:46 AM, Griffith, Michael * >> <michael.griff...@fda.hhs.gov> wrote: >>> I also tried adding the @Autowired annotation to the dependency, but >>> it did not work. Can anyone clarify how this is supposed to work? >>> MG >>> >>> -----Original Message----- >>> From: Steven Yang [mailto:kenshin...@gmail.com] >>> Sent: Thursday, February 05, 2009 8:15 PM >>> To: Struts Users Mailing List >>> Subject: Re: TypeConverter needs Spring Bean >>> >>> Hi >>> I also need my Converter to be handled by Spring however I could not >>> get it to work as well. >>> From my observation is that the Converter is set to X-Work but not to > >>> Struts, there for the Spring plugin may not work there. >>> Please correct me if I am wrong. >>> Or is there a correct way to set it up? >>> >>> Thanks > -- View this message in context: http://www.nabble.com/TypeConverter-needs-Spring-Bean-tp21859590p25790977.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org