I faced the same problem and I'm using the constructor's injection instead. But why wouldn't the deprecated @InjectResource nor the @Inject annotation work ? I'm using tapestry5.3.1
On Wed, Dec 29, 2010 at 1:33 AM, Howard Lewis Ship <hls...@gmail.com> wrote: > You're seeing the evolution of the framework. > > Originally, there was only constructor injection for services. This is > because we did not, originally, use a special class loader for service > implementations and we were trying to avoid reflection. > > Components always used a special class loader, which allowed for proper > injection (including intercepting attempted updates to the fields, to make > the read-only). > > Later (5.1 I believe) we started allowing injection into fields of service > implementation, using reflection. > > However, there's an ambiguity. Normally, once Tapestry selects a > constructor, it provides an injection value for each parameter, based on > type (and other annotation). > > Normally, a component parameter of type Logger is recognized, by type, as a > service resource (i.e., not another service, but a unique value constructed > just for this service). Adding the @Inject annotation tells Tapestry to > ignore it as a service resource and resolve it as an ordinary injection > (i.e., a service, or an object obtained from the MasterObjectProvider). > > For fields, each field needs an @Inject annotation (Tapestry ignores most > fields and only performs injection on the ones that need it). But > that ambiguity ... @Inject should also work the same for a field as it does > for a parameter (meaning, resolve as a service, not a resource). The > solution was yet another annotation, @InjectResource, which is only for > fields, and indicates that Tapestry should perform a resource injection on > the field, as it would for a constructor parameter. > > Confusing? Yes, just a touch. It's one of the reasons I prefer constructor > injection. > > On Tue, Dec 28, 2010 at 3:15 PM, Thiago H. de Paula Figueiredo < > thiag...@gmail.com> wrote: > > > On Tue, 28 Dec 2010 21:11:58 -0200, Josh Canfield < > joshcanfi...@gmail.com> > > wrote: > > > > Weird. Has that always been true? > >> > > > > No. I can't remember when, though. > > > > > > I'm also confused > >> why @Inject would work with Logger in a Component, but not in a service. > >> > > > > Injection of some object types are handled by class transformations, not > > IoC. > > > > > > -- > > Thiago H. de Paula Figueiredo > > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > > and instructor > > Owner, Ars Machina Tecnologia da Informação Ltda. > > http://www.arsmachina.com.br > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > > > > -- > Howard M. Lewis Ship > > Creator of Apache Tapestry > > The source for Tapestry training, mentoring and support. Contact me to > learn > how I can get you up and productive in Tapestry fast! > > (971) 678-5210 > http://howardlewisship.com > -- *Regards,* *Muhammad Gelbana Java Developer*