you could also use the ObjectLocator service to create proxies within the alias contribution to prevent the recursion
pblic void static contributeAliasOverrides(Configuration.... , ObjectLocator locator) { configuration.add(AliasContribution.create(LinkFactory.class, locator.proxy(LinkFactory.class, YourImplementation.class))); } g, kris Robert Zeigler <robe...@scazdl.org> Gesendet von: robert zeigler <robert.zeig...@gmail.com> 18.02.2009 05:13 Bitte antworten an "Tapestry users" <users@tapestry.apache.org> An "Tapestry users" <users@tapestry.apache.org> Kopie Thema Re: [T5.1] Overriding a binding? The problem is that the alias service is needed to dereference some of the objects used by your SiteLinkFactory service, but you're contributing SiteLinkFactory to alias, hence the recursive dependency problem. Try contributing to AliasOverrides, instead of Alias, which is really what you want. Cheers, Robert On Feb 17, 2009, at 2/177:43 PM , xfile80303 wrote: > > Thanks for the fast reply Thiago! > > I have tried to set this up in my Module class: > > public static void bind(ServiceBinder binder) > { > binder.bind(SiteLinkFactory.class).withId("SiteLinkFactory"); > } > > public static void contributeAlias( > Configuration<AliasContribution> configuration, > @Local SiteLinkFactory siteLinkFactory) > { > > configuration.add(AliasContribution.create(LinkFactory.class, > siteLinkFactory)); > } > > > But I get a recursion exception when trying to load the web app. > This type > of issue seems fairly common on the mailing list, but I've not found a > solution which works here yet. > > As a baseline I've tried to create an alias for the LinkFactoryImpl > class > instead of my own, but I get the same issue. > > This seems to imply there is some dependency in the implementation > of the > LinkFactoryImpl class which has a circular reference? > > The LinkFactoryImpl takes these as arguments to its constructor, > might one > be the issue? > > Request request, Response response, > RequestSecurityManager requestSecurityManager, > RequestPathOptimizer optimizer, PersistentLocale persistentLocale, > RequestPageCache requestPageCache, > ContextValueEncoder valueEncoder, URLEncoder urlEncoder > > Any thoughts on if I'm doing something wrong in setting up this > alias, or a > way to work around this seemingly circular reference? > > The exception: > java.lang.RuntimeException: Exception constructing service > 'ServletApplicationInitializer': Unable to instantiate class > org.apache.tapestry5.services.TapestryModule as a module: Exception > constructing service 'Alias': Error invoking service builder method > org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, > String, > AliasManager, Collection) (at TapestryModule.java:315) (for service > 'Alias'): Error invoking service contribution method > com.java.dse.cwp.eos.services.EosModule.contributeAlias(Configuration, > SiteLinkFactory): Error building service proxy for service > 'SiteLinkFactory' > (at com.java.dse.cwp.eos.services.util.SiteLinkFactory(Request, > Response, > RequestSecurityManager, RequestPathOptimizer, PersistentLocale, > RequestPageCache, ContextValueEncoder, URLEncoder) (at > SiteLinkFactory.java:58) via > com.java.dse.cwp.eos.services.EosModule.bind(ServiceBinder) (at > EosModule.java:52)): Error invoking constructor > com.java.dse.cwp.eos.services.util.SiteLinkFactory(Request, Response, > RequestSecurityManager, RequestPathOptimizer, PersistentLocale, > RequestPageCache, ContextValueEncoder, URLEncoder) (at > SiteLinkFactory.java:58) via > com.java.dse.cwp.eos.services.EosModule.bind(ServiceBinder) (at > EosModule.java:52) (for service 'SiteLinkFactory'): Exception > constructing > service 'Alias': Construction of service 'Alias' has failed due to > recursion: the service depends on itself in some way. Please check > org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, > String, > AliasManager, Collection) (at TapestryModule.java:315) for > references to > another service that is itself dependent on service 'Alias'. > > Thanks, > > Levi > > > Thiago H. de Paula Figueiredo wrote: >> >> Em Tue, 17 Feb 2009 21:57:36 -0300, xfile80303 <l...@grokers.net> >> escreveu: >> >>> I need to override an existing binding so I can insert my own >>> implementation, but I get a RuntimeException from Tapestry when I >>> try to >>> do so. How would I do this? >> >> Using aliases: http://tapestry.apache.org/tapestry5/guide/alias.html. >> > > -- > View this message in context: http://n2.nabble.com/-T5.1--Overriding-a-binding--tp2344287p2344459.html > Sent from the Tapestry Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org